Class: Rocknab::Builders::Number
- Inherits:
-
Struct
- Object
- Struct
- Rocknab::Builders::Number
- Defined in:
- lib/rocknab/builder/number.rb
Instance Attribute Summary collapse
-
#default ⇒ Object
Returns the value of attribute default.
-
#length ⇒ Object
Returns the value of attribute length.
-
#name ⇒ Object
Returns the value of attribute name.
-
#padding ⇒ Object
Returns the value of attribute padding.
Instance Method Summary collapse
Instance Attribute Details
#default ⇒ Object
Returns the value of attribute default
3 4 5 |
# File 'lib/rocknab/builder/number.rb', line 3 def default @default end |
#length ⇒ Object
Returns the value of attribute length
3 4 5 |
# File 'lib/rocknab/builder/number.rb', line 3 def length @length end |
#name ⇒ Object
Returns the value of attribute name
3 4 5 |
# File 'lib/rocknab/builder/number.rb', line 3 def name @name end |
#padding ⇒ Object
Returns the value of attribute padding
3 4 5 |
# File 'lib/rocknab/builder/number.rb', line 3 def padding @padding end |
Instance Method Details
#build(klass) ⇒ Object
4 5 6 7 |
# File 'lib/rocknab/builder/number.rb', line 4 def build(klass) value = klass.instance_variable_get("@#{name}") || default value.to_s[0...length].rjust(length, padding.to_s) end |