Class: Less::Node::Number
- Inherits:
-
Float
- Object
- Float
- 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
- #dup ⇒ Object
-
#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.
89 90 91 92 |
# File 'lib/less/engine/nodes/literal.rb', line 89 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.
87 88 89 |
# File 'lib/less/engine/nodes/literal.rb', line 87 def unit @unit end |
Instance Method Details
#dup ⇒ Object
98 99 100 |
# File 'lib/less/engine/nodes/literal.rb', line 98 def dup self end |
#inspect ⇒ Object
106 107 108 |
# File 'lib/less/engine/nodes/literal.rb', line 106 def inspect to_s end |
#to_css ⇒ Object
110 111 112 |
# File 'lib/less/engine/nodes/literal.rb', line 110 def to_css "#{(self % 1).zero?? "#{self.to_i}#@unit" : self}" end |
#to_ruby ⇒ Object
102 103 104 |
# File 'lib/less/engine/nodes/literal.rb', line 102 def to_ruby self.to_f end |
#to_s ⇒ Object
94 95 96 |
# File 'lib/less/engine/nodes/literal.rb', line 94 def to_s "#{super}#@unit" end |