<commit_before>module Dill
  module WidgetParts
    module Struct
      def self.included(target)
        target.extend ClassMethods
      end

      module ClassMethods
        def attribute(name, *args, &block)
          child = widget(name, *args, &block)

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

          child
        end

        def boolean(name, *args, &block)
          child = widget(name, *args, &block)

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

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

          child
        end

        def date(name, *args, &block)
          child = attribute(name, *args, &block)

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

          child
        end

        def float(name, *args, &block)
          child = attribute(name, *args, &block)

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

          child
        end

        def integer(name, *args, &block)
          child = attribute(name, *args, &block)

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

          child
        end

        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}).dynamic_value
            end
          WIDGET

          child.class_eval(&block) if block_given?

          child
        end

        def string(name, *args, &block)
          child = attribute(name, *args, &block)

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

          child
        end

        def time(name, *args, &block)
          child = attribute(name, *args, &block)

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

          child
        end
      end
    end
  end
end
<commit_msg>[widget] Use focused struct attribute arguments.<commit_after>module Dill
  module WidgetParts
    module Struct
      def self.included(target)
        target.extend ClassMethods
      end

      module ClassMethods
        def attribute(name, selector, &block)
          child = widget(name, selector, &block)

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

          child
        end

        def boolean(name, selector, &block)
          child = widget(name, selector, &block)

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

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

          child
        end

        def date(name, selector, &block)
          child = attribute(name, selector, &block)

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

          child
        end

        def float(name, selector, &block)
          child = attribute(name, selector, &block)

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

          child
        end

        def integer(name, selector, &block)
          child = attribute(name, selector, &block)

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

          child
        end

        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}).dynamic_value
            end
          WIDGET

          child.class_eval(&block) if block_given?

          child
        end

        def string(name, *args, &block)
          child = attribute(name, *args, &block)

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

          child
        end

        def time(name, *args, &block)
          child = attribute(name, *args, &block)

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

          child
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.08314878196094222, 'fraction_numerical': 0.0, 'mean_word_length': 1.2129175946547883, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3375770', 'n_tokens_mistral': 1314, 'n_tokens_neox': 1256, 'n_words': 347}