Class: Ruco::Form
Instance Method Summary collapse
- #cursor ⇒ Object
-
#initialize(label, options, &submit) ⇒ Form
constructor
A new instance of Form.
- #insert(text) ⇒ Object
- #reset ⇒ Object
- #style_map ⇒ Object
- #view ⇒ Object
Constructor Details
#initialize(label, options, &submit) ⇒ Form
Returns a new instance of Form.
5 6 7 8 9 10 |
# File 'lib/ruco/form.rb', line 5 def initialize(label, , &submit) @options = @label = label.strip + ' ' @submit = submit reset end |
Instance Method Details
#cursor ⇒ Object
27 28 29 |
# File 'lib/ruco/form.rb', line 27 def cursor Position.new 0, @label.size + @text_field.cursor.column end |
#insert(text) ⇒ Object
22 23 24 25 |
# File 'lib/ruco/form.rb', line 22 def insert(text) @text_field.insert(text.gsub("\n",'')) unless text == "\n" @submit.call(@text_field.value) if text.include?("\n") or @options[:auto_enter] end |
#reset ⇒ Object
31 32 33 |
# File 'lib/ruco/form.rb', line 31 def reset @text_field = TextField.new(:columns => @options[:columns] - @label.size) end |
#style_map ⇒ Object
16 17 18 19 20 |
# File 'lib/ruco/form.rb', line 16 def style_map map = @text_field.style_map map.left_pad!(@label.size) map end |
#view ⇒ Object
12 13 14 |
# File 'lib/ruco/form.rb', line 12 def view @label + @text_field.view end |