Module: Danica::Wrapper
Defined Under Namespace
Classes: Constant, Container, Group, Negative, Number, PlusMinus, Variable
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.wrap_hash(hash) ⇒ Object
40
41
42
43
44
|
# File 'lib/danica/wrapper.rb', line 40
def self.wrap_hash(hash)
return Constant.new(hash) if hash.keys.map(&:to_sym).sort == %i[gnuplot latex value]
Variable.new(hash)
end
|
.wrap_numeric(number) ⇒ Object
34
35
36
37
38
|
# File 'lib/danica/wrapper.rb', line 34
def self.wrap_numeric(number)
return Negative.new(Number.new(-number)) if number < 0
Number.new(number)
end
|
.wrap_value(value) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/danica/wrapper.rb', line 17
def self.wrap_value(value)
case value
when Formatted
value.content
when Numeric
wrap_numeric(value)
when Hash
wrap_hash(value)
when String, Symbol, NilClass
Variable.new(name: value)
else
raise Exception::InvalidInput, value unless value.is_a?(Danica::Common)
value
end
end
|
Instance Method Details
#wrap_value(value) ⇒ Object
13
14
15
|
# File 'lib/danica/wrapper.rb', line 13
def wrap_value(value)
Wrapper.wrap_value(value)
end
|