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.



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

#unitObject

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

#inspectObject



70
71
72
# File 'lib/less/engine/nodes/literal.rb', line 70

def inspect
  to_s
end

#to_cssObject



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_rubyObject



66
67
68
# File 'lib/less/engine/nodes/literal.rb', line 66

def to_ruby
  self.to_f
end

#to_sObject



62
63
64
# File 'lib/less/engine/nodes/literal.rb', line 62

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