Class: Clamp::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/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/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/clamp/attribute.rb', line 5

def default_value
  @default_value
end

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#environment_variableObject (readonly)

Returns the value of attribute environment_variable.



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

def environment_variable
  @environment_variable
end

Instance Method Details

#default_methodObject



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

def default_method
  "default_#{read_method}"
end

#helpObject



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

def help
  [help_lhs, help_rhs]
end

#help_rhsObject



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

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

#ivar_nameObject



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

def ivar_name
  "@#{attribute_name}"
end

#read_methodObject



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

def read_method
  attribute_name
end

#write_methodObject



34
35
36
# File 'lib/clamp/attribute.rb', line 34

def write_method
  "#{attribute_name}="
end