Class: Gambit::Server::Game::EventForm
- Inherits:
-
Object
- Object
- Gambit::Server::Game::EventForm
- Includes:
- Viewable
- Defined in:
- lib/gambit/server/game/eventform.rb
Instance Method Summary collapse
- #checks(group, names, options = Hash.new) ⇒ Object
- #document(name, default_text = nil, options = Hash.new) ⇒ Object
- #hidden(name, value) ⇒ Object
- #html(tags) ⇒ Object
-
#initialize(url, intro, hidden, &init) ⇒ EventForm
constructor
A new instance of EventForm.
- #menu(name, values, options = Hash.new, menu_options = Hash.new) ⇒ Object
- #password(name, options = Hash.new) ⇒ Object
- #radios(group, names, options = Hash.new) ⇒ Object
- #reset(name, options = Hash.new) ⇒ Object
- #submit(name, options = Hash.new) ⇒ Object
- #text(name, options = Hash.new) ⇒ Object
Methods included from Viewable
Constructor Details
#initialize(url, intro, hidden, &init) ⇒ EventForm
Returns a new instance of EventForm.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/gambit/server/game/eventform.rb', line 69 def initialize( url, intro, hidden, &init ) @url = url @intro = intro @elements = Array.new @hidden_fields = Array.new submit("Submit") reset("Reset") @element_style = :dl hidden.each { |(name, value)| hidden(name, value) } self.instance_eval(&init) end |
Instance Method Details
#checks(group, names, options = Hash.new) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/gambit/server/game/eventform.rb', line 84 def checks( group, names, = Hash.new ) = "" names.each do |name| << " <input type=\"checkbox\" " + "id=\"#{name}\" " + "name=\"#{group}\" value=\"#{name}\"" + "#{htmlify([name])} />" + "<label for=\"#{name}\">" + "#{name.capitalize.tr("_", " ")}</label>" end @elements << .strip end |
#document(name, default_text = nil, options = Hash.new) ⇒ Object
97 98 99 100 101 |
# File 'lib/gambit/server/game/eventform.rb', line 97 def document( name, default_text = nil, = Hash.new ) @elements << "<textarea id=\"#{name}\" name=\"#{name}\"" + "#{htmlify()}>" + "#{default_text || ''}</textarea>" end |
#hidden(name, value) ⇒ Object
103 104 105 106 107 |
# File 'lib/gambit/server/game/eventform.rb', line 103 def hidden( name, value ) @hidden_fields << "<input type=\"hidden\" " + "name=\"#{name}\" " + "value=\"#{value}\" />" end |
#html(tags) ⇒ Object
109 110 111 112 113 |
# File 'lib/gambit/server/game/eventform.rb', line 109 def html( ) @element_style = :p @elements << end |
#menu(name, values, options = Hash.new, menu_options = Hash.new) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/gambit/server/game/eventform.rb', line 115 def ( name, values, = Hash.new, = Hash.new ) = "<select id=\"#{name}\" name=\"#{name}\"" + "#{htmlify()}>" << values.map do |value| "<option value=\"#{value}\"" + "#{htmlify([value])}>" + "#{value.capitalize.tr("_", " ")}</option>" end.join << "</select>" @elements << .strip end |
#password(name, options = Hash.new) ⇒ Object
128 129 130 131 132 |
# File 'lib/gambit/server/game/eventform.rb', line 128 def password( name, = Hash.new ) @elements << "<input type=\"password\" " + "id=\"#{name}\" name=\"#{name}\"" + "#{htmlify()} />" end |
#radios(group, names, options = Hash.new) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/gambit/server/game/eventform.rb', line 134 def radios( group, names, = Hash.new ) = "" names.each do |name| << " <input type=\"radio\" " + "id=\"#{name}\" " + "name=\"#{group}\" value=\"#{name}\"" + "#{htmlify([name])} />" + "<label for=\"#{name}\">" + "#{name.capitalize.tr("_", " ")}</label>" end @elements << .strip end |
#reset(name, options = Hash.new) ⇒ Object
147 148 149 150 |
# File 'lib/gambit/server/game/eventform.rb', line 147 def reset( name, = Hash.new ) @reset = "<input type=\"reset\" value=\"#{name}\"" + "#{htmlify()} />" end |
#submit(name, options = Hash.new) ⇒ Object
152 153 154 155 |
# File 'lib/gambit/server/game/eventform.rb', line 152 def submit( name, = Hash.new ) @submit = "<input type=\"submit\" value=\"#{name}\"" + "#{htmlify()} />" end |
#text(name, options = Hash.new) ⇒ Object
157 158 159 160 161 |
# File 'lib/gambit/server/game/eventform.rb', line 157 def text( name, = Hash.new ) @elements << "<input type=\"text\" " + "id=\"#{name}\" name=\"#{name}\"" + "#{htmlify()} />" end |