Class: Danica::Wrapper::Number

Inherits:
Object
  • Object
show all
Includes:
BaseOperations, Common
Defined in:
lib/danica/wrapper/number.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Common

#content, #formatted, #gnu, #tex, #to_f, #to_gnu, #to_tex

Methods included from BaseOperations

#*, #**, #+, #-, #-@, #/

Constructor Details

#initialize(value) ⇒ Number

Returns a new instance of Number.



14
15
16
# File 'lib/danica/wrapper/number.rb', line 14

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



8
9
10
# File 'lib/danica/wrapper/number.rb', line 8

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



33
34
35
36
37
# File 'lib/danica/wrapper/number.rb', line 33

def ==(other)
  return false unless other.class == self.class

  value == other.value
end

#signaled?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/danica/wrapper/number.rb', line 29

def signaled?
  value < 0
end

#to(_format, decimals: nil, **_options) ⇒ Object



18
19
20
21
22
23
# File 'lib/danica/wrapper/number.rb', line 18

def to(_format, decimals: nil, **_options)
  return value.to_i.to_s if value.to_i == value
  return format("%.#{decimals}f", value).to_f.to_s if decimals

  value.to_s
end

#valued?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/danica/wrapper/number.rb', line 25

def valued?
  value.present?
end