Module: Dill::Constructors
- Included in:
- Dill
- Defined in:
- lib/dill/widgets.rb
Instance Method Summary collapse
- #Decimal(*selector) ⇒ Object
- #Integer(*selector) ⇒ Object
- #Widget(*selector, &block) ⇒ Object (also: #String)
Instance Method Details
#Decimal(*selector) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/dill/widgets.rb', line 28 def Decimal(*selector) Widget(selector) { |text| # ensure we can convert to float first Float(text) && BigDecimal.new(text) } end |
#Integer(*selector) ⇒ Object
22 23 24 |
# File 'lib/dill/widgets.rb', line 22 def Integer(*selector) Widget(selector) { |text| Kernel::Integer(text) } end |
#Widget(*selector, &block) ⇒ Object Also known as: String
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/dill/widgets.rb', line 8 def Widget(*selector, &block) if block_given? WidgetClass.new(selector.flatten) do define_method :value do block.call(text) end end else WidgetClass.new(selector.flatten) end end |