Class: Clamp::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/wpb/clamp/attribute.rb

Direct Known Subclasses

Option, Parameter

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attribute_nameObject (readonly)

Returns the value of attribute attribute_name.



5
6
7
# File 'lib/wpb/clamp/attribute.rb', line 5

def attribute_name
  @attribute_name
end

#default_valueObject (readonly)

Returns the value of attribute default_value.



5
6
7
# File 'lib/wpb/clamp/attribute.rb', line 5

def default_value
  @default_value
end

#descriptionObject (readonly)

Returns the value of attribute description.



5
6
7
# File 'lib/wpb/clamp/attribute.rb', line 5

def description
  @description
end

Instance Method Details

#default_methodObject



27
28
29
# File 'lib/wpb/clamp/attribute.rb', line 27

def default_method
  "default_#{read_method}"
end

#helpObject



15
16
17
# File 'lib/wpb/clamp/attribute.rb', line 15

def help
  [help_lhs, help_rhs]
end

#help_rhsObject



7
8
9
10
11
12
13
# File 'lib/wpb/clamp/attribute.rb', line 7

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

#ivar_nameObject



19
20
21
# File 'lib/wpb/clamp/attribute.rb', line 19

def ivar_name
  "@#{attribute_name}"
end

#read_methodObject



23
24
25
# File 'lib/wpb/clamp/attribute.rb', line 23

def read_method
  attribute_name
end

#write_methodObject



31
32
33
# File 'lib/wpb/clamp/attribute.rb', line 31

def write_method
  "#{attribute_name}="
end