Class: Less::Node::Number
- Includes:
- Literal
- Defined in:
- lib/less/engine/nodes/literal.rb
Overview
6 10px 125%
Instance Attribute Summary collapse
-
#unit ⇒ Object
Returns the value of attribute unit.
Attributes included from Entity
Instance Method Summary collapse
-
#initialize(value, unit = nil) ⇒ Number
constructor
A new instance of Number.
- #inspect ⇒ Object
- #to_css ⇒ Object
- #to_ruby ⇒ Object
- #to_s ⇒ Object
Methods included from Entity
Constructor Details
#initialize(value, unit = nil) ⇒ Number
Returns a new instance of Number.
57 58 59 60 |
# File 'lib/less/engine/nodes/literal.rb', line 57 def initialize value, unit = nil super value.to_f @unit = (unit.nil? || unit.empty?) ? nil : unit end |
Instance Attribute Details
#unit ⇒ Object
Returns the value of attribute unit.
55 56 57 |
# File 'lib/less/engine/nodes/literal.rb', line 55 def unit @unit end |
Instance Method Details
#inspect ⇒ Object
70 71 72 |
# File 'lib/less/engine/nodes/literal.rb', line 70 def inspect to_s end |
#to_css ⇒ Object
74 75 76 |
# File 'lib/less/engine/nodes/literal.rb', line 74 def to_css "#{(self % 1).zero?? self.to_i.to_s : self.to_s}#@unit" end |
#to_ruby ⇒ Object
66 67 68 |
# File 'lib/less/engine/nodes/literal.rb', line 66 def to_ruby self.to_f end |
#to_s ⇒ Object
62 63 64 |
# File 'lib/less/engine/nodes/literal.rb', line 62 def to_s "#{super}#@unit" end |