Sha256: cb5854426497b9bef7442cc2007c56720a4182fa875c0320acc0feb8e0e8c64a

Contents?: true

Size: 562 Bytes

Versions: 8

Compression:

Stored size: 562 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

8 entries across 8 versions & 2 rubygems

Version Path
clamp-0.3.0 lib/clamp/attribute.rb
clamp-0.2.3 lib/clamp/attribute.rb
clamp-0.2.2 lib/clamp/attribute.rb
clamp-0.2.1 lib/clamp/attribute.rb
clamp-0.2.0 lib/clamp/attribute.rb
wpb-0.0.5 lib/wpb/clamp/attribute.rb
clamp-0.1.8 lib/clamp/attribute.rb
clamp-0.1.7 lib/clamp/attribute.rb