Class: Less::Node::Number

Inherits:
Float
  • Object
show all
Includes:
Literal
Defined in:
lib/less/engine/nodes/literal.rb

Overview

6 10px 125%

Instance Attribute Summary collapse

Attributes included from Entity

#parent

Instance Method Summary collapse

Methods included from Entity

#path, #root

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

#unitObject

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

#dupObject



98
99
100
# File 'lib/less/engine/nodes/literal.rb', line 98

def dup
  self
end

#inspectObject



106
107
108
# File 'lib/less/engine/nodes/literal.rb', line 106

def inspect
  to_s
end

#to_cssObject



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_rubyObject



102
103
104
# File 'lib/less/engine/nodes/literal.rb', line 102

def to_ruby
  self.to_f
end

#to_sObject



94
95
96
# File 'lib/less/engine/nodes/literal.rb', line 94

def to_s
  "#{super}#@unit"
end