Class: OpenTox::PostCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/to-html.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, name = "Send") ⇒ PostCommand

Returns a new instance of PostCommand.



88
89
90
91
92
# File 'lib/to-html.rb', line 88

def initialize( uri, name="Send" )
  @uri = uri
  @name = name
  @attributes = []
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



86
87
88
# File 'lib/to-html.rb', line 86

def attributes
  @attributes
end

#nameObject

Returns the value of attribute name.



86
87
88
# File 'lib/to-html.rb', line 86

def name
  @name
end

#uriObject

Returns the value of attribute uri.



86
87
88
# File 'lib/to-html.rb', line 86

def uri
  @uri
end

Instance Method Details

#to_htmlObject



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/to-html.rb', line 94

def to_html
  html = "<form method='POST' action='"+@uri.to_s+"'>"
  html << "<pre><p>"
  html << "<table border=0>"
  #html << "<tr><td colspan='3'><i><sup>Mandatory params are marked with *.</sup></i></td></tr>"
  attributes.each do |a|
    mandatory_string = a.is_mandatory ? "*" : ""
    html << "<tr><td>"+a.name.to_s+":"+mandatory_string+"</td>"
    html << "<td><input type='text' name='"+a.name.to_s+
      "' size='50' value='"+a.default.to_s+"'/></td>"
    html << "<td><i><sup>"+a.description.to_s+"</sup></i></td></tr>"
  end
  html << "<tr><td colspan='3'><input type='submit' value='"+@name.to_s+"' /></td></tr>"
  html << "</table></p></pre></form>"
  html
end