Sha256: db8df495e668fad177c4338252dbbc7c6c0206073be523127549798074b74654

Contents?: true

Size: 538 Bytes

Versions: 1

Compression:

Stored size: 538 Bytes

Contents

module Clamp

  class Attribute

    attr_reader :description, :attribute_name, :default_value

    def help_rhs
      rhs = description
      if defined?(@default_value)
        rhs += " (default: #{@default_value.inspect})"
      end
      rhs
    end

    def help
      [help_lhs, help_rhs]
    end

    def ivar_name
      "@#{attribute_name}"
    end

    def read_method
      attribute_name
    end

    def default_method
      "default_#{read_method}"
    end

    def write_method
      "#{attribute_name}="
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
clamp-0.3.1 lib/clamp/attribute.rb