Class: Rocknab::Builders::Number

Inherits:
Struct
  • Object
show all
Defined in:
lib/rocknab/builder/number.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#defaultObject

Returns the value of attribute default

Returns:

  • (Object)

    the current value of default



3
4
5
# File 'lib/rocknab/builder/number.rb', line 3

def default
  @default
end

#lengthObject

Returns the value of attribute length

Returns:

  • (Object)

    the current value of length



3
4
5
# File 'lib/rocknab/builder/number.rb', line 3

def length
  @length
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



3
4
5
# File 'lib/rocknab/builder/number.rb', line 3

def name
  @name
end

#paddingObject

Returns the value of attribute padding

Returns:

  • (Object)

    the current value of 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