如何用ruby打开默认的应用程序文件?

时间:2017-02-09 09:07:41

标签: ruby

如何打开默认的应用程序文件?

例如,我将打开文件然后打开Picture.png是图像查看器。

我如何用红宝石做到这一点?

1 个答案:

答案 0 :(得分:3)

试试“launchy”宝石

安装gem:

<!DOCTYPE HTML>
  <html>
  
    <head>
    
      <meta charset="utf-8">
      
      <title>AJAX + PHP форма</title>
      
      <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
      
      <style type="text/css">
        
        .input_group {
          
          display:inline-block;
          padding: 5px;
          width:100%;
          text-align: center;
          
        }
        
        form {
          
          width: 50%;
          
        }
        
        #send_message {
          text-align: center;
        }
        
      </style>
        
      
    </head>
    
    <body>
      
      <form id="contact" action="">
        
        <fieldset>
          
          <legend>AJAX + PHP форма</legend>
          
            <div class = "input_group">
        
              <label for="name" id="name_label">Имя</label> <br/>

              <input type="text" name="name" id="name" size="50" value="" class="text-input" required = "required"/>
              
            </div>
          
            <br/>
          
            <div class = "input_group">

              <label for="company" id="company_label">Компания</label> <br/>

              <input type="text" name="company" id="company" size="50" value="" class="text-input" required = "required" />
              
            </div>
              
            <br/>
          
            <div class = "input_group">
              
              <label for="phone" id="phone_label">Телефон</label> <br/>

              <input type="text" name="phone" id="phone" size="50" value="" class="text-input" required = "required" />
              
            </div>
          
            <br/>
              
            <div class = "input_group">
              
              <label for="msg_text" id="msg_label">Запрос</label> <br/>

              <textarea rows="6" cols="51" name="question" id="message" required = "required"></textarea>
            
            </div>
          
            <div class = "input_group">
        
              <input type="submit" onclick="myFunction()" id="submit" value="Отправить" />
              
            </div>
            
          </fieldset>
        
      </form>
      
      <h2 style="display:none;" id ="error">Заполните все поля!</h2>
      <h2 style="display:none;" id="success">Message sent!</h2>

然后在您的Ruby程序中执行以下操作:

$ gem install launchy