Class: Rocknab::Builders::Text
- Inherits:
-
Struct
- Object
- Struct
- Rocknab::Builders::Text
- Defined in:
- lib/rocknab/builder/text.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/text.rb', line 3 def default @default end |
#length ⇒ Object
Returns the value of attribute length
3 4 5 |
# File 'lib/rocknab/builder/text.rb', line 3 def length @length end |
#name ⇒ Object
Returns the value of attribute name
3 4 5 |
# File 'lib/rocknab/builder/text.rb', line 3 def name @name end |
#padding ⇒ Object
Returns the value of attribute padding
3 4 5 |
# File 'lib/rocknab/builder/text.rb', line 3 def padding @padding end |
Instance Method Details
#build(klass) ⇒ Object
4 5 6 7 |
# File 'lib/rocknab/builder/text.rb', line 4 def build(klass) value = klass.instance_variable_get("@#{name}") || default value.to_s.upcase[0...length].ljust(length, padding.to_s) end |