module Dill::WidgetParts::Struct::ClassMethods

Public Instance Methods

attribute(name, selector, &block) click to toggle source
# File lib/dill/widgets/parts/struct.rb, line 9
        def attribute(name, selector, &block)
          child = widget(name, selector, &block)

          class_eval <<-WIDGET
            def #{name}
              widget(:#{name}).value
            end
          WIDGET

          child
        end
boolean(name, selector, &block) click to toggle source
# File lib/dill/widgets/parts/struct.rb, line 21
        def boolean(name, selector, &block)
          child = widget(name, selector, &block)

          class_eval <<-WIDGET
            def #{name}?
              widget(:#{name}).value
            end
          WIDGET

          child.class_eval <<-VALUE
            def value
              Dill::Conversions::Boolean(text)
            end
          VALUE

          child
        end
date(name, selector, &block) click to toggle source
# File lib/dill/widgets/parts/struct.rb, line 39
        def date(name, selector, &block)
          child = attribute(name, selector, &block)

          child.class_eval <<-VALUE
            def value
              Date.parse(text)
            end
          VALUE

          child
        end
float(name, selector, &block) click to toggle source
# File lib/dill/widgets/parts/struct.rb, line 51
        def float(name, selector, &block)
          child = attribute(name, selector, &block)

          child.class_eval <<-VALUE
            def value
              Float(text)
            end
          VALUE

          child
        end
integer(name, selector, &block) click to toggle source
# File lib/dill/widgets/parts/struct.rb, line 63
        def integer(name, selector, &block)
          child = attribute(name, selector, &block)

          child.class_eval <<-VALUE
            def value
              Integer(text)
            end
          VALUE

          child
        end
list(name, selector, options = {}, &block) click to toggle source
# File lib/dill/widgets/parts/struct.rb, line 75
        def list(name, selector, options = {}, &block)
          child = widget(name, selector, Dill::List) do
            item options[:item_selector], options[:item_class] || ListItem
          end

          class_eval <<-WIDGET
            def #{name}
              widget(:#{name}).value
            end
          WIDGET

          child.class_eval(&block) if block_given?

          child
        end
string(name, *args, &block) click to toggle source
# File lib/dill/widgets/parts/struct.rb, line 91
        def string(name, *args, &block)
          child = attribute(name, *args, &block)

          child.class_eval <<-VALUE
            def value
              text
            end
          VALUE

          child
        end
time(name, *args, &block) click to toggle source
# File lib/dill/widgets/parts/struct.rb, line 103
        def time(name, *args, &block)
          child = attribute(name, *args, &block)

          child.class_eval <<-VALUE
            def value
              Time.parse(text)
            end
          VALUE

          child
        end