Module: IRuby::Input

Included in:
IRuby
Defined in:
lib/iruby/input.rb,
lib/iruby/input/date.rb,
lib/iruby/input/file.rb,
lib/iruby/input/form.rb,
lib/iruby/input/field.rb,
lib/iruby/input/label.rb,
lib/iruby/input/popup.rb,
lib/iruby/input/radio.rb,
lib/iruby/input/button.rb,
lib/iruby/input/cancel.rb,
lib/iruby/input/select.rb,
lib/iruby/input/widget.rb,
lib/iruby/input/builder.rb,
lib/iruby/input/checkbox.rb,
lib/iruby/input/textarea.rb

Defined Under Namespace

Classes: Builder, Button, Cancel, Checkbox, Date, Field, File, InputForm, Label, Popup, Radio, Select, Textarea, Widget

Instance Method Summary collapse

Instance Method Details

#form(&block) ⇒ Object


17
18
19
20
21
22
23
24
25
# File 'lib/iruby/input.rb', line 17

def form &block
  builder = Builder.new &block
  form = InputForm.new(
    fields: builder.fields, 
    buttons: builder.buttons
  )
  form.widget_display
  builder.process_result form.submit
end

#input(prompt = 'Input') ⇒ Object


7
8
9
10
# File 'lib/iruby/input.rb', line 7

def input prompt='Input'
  result = form{input label: prompt}
  result[:input] unless result.nil?
end

#password(prompt = 'Password') ⇒ Object


12
13
14
15
# File 'lib/iruby/input.rb', line 12

def password prompt='Password'
  result = form{password label: prompt}
  result[:password] unless result.nil?
end

27
28
29
30
31
32
33
34
35
36
37
# File 'lib/iruby/input.rb', line 27

def popup title='Input', &block
  builder = Builder.new &block
  form = InputForm.new fields: builder.fields
  popup = Popup.new(
    title: title, 
    form: form, 
    buttons: builder.buttons
  )
  popup.widget_display
  builder.process_result form.submit
end