Module: Danica::Common

Extended by:
ActiveSupport::Concern
Included in:
Expression, Function::Name, VariablesHolder, Wrapper::Constant, Wrapper::Container, Wrapper::Group, Wrapper::Number, Wrapper::Variable
Defined in:
lib/danica/common.rb

Instance Method Summary collapse

Instance Method Details

#contentObject



70
71
72
# File 'lib/danica/common.rb', line 70

def content
  self
end

#formatted(*args) ⇒ Object



60
61
62
# File 'lib/danica/common.rb', line 60

def formatted(*args)
  Formatted.new(self, *args)
end

#gnu(**options) ⇒ Object



56
57
58
# File 'lib/danica/common.rb', line 56

def gnu(**options)
  formatted(format: :gnu, **options)
end

#tex(**options) ⇒ Object



52
53
54
# File 'lib/danica/common.rb', line 52

def tex(**options)
  formatted(format: :tex, **options)
end

#to(format, **options) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/danica/common.rb', line 39

def to(format, **options)
  case format.to_sym
  when :tex
    to_tex(options)
  when :gnu
    to_gnu(options)
  when :f
    to_f
  else
    raise Exception::FormattedNotFound
  end
end

#to_fObject



27
28
29
# File 'lib/danica/common.rb', line 27

def to_f
  raise Exception::NotImplemented
end

#to_gnu(**options) ⇒ Object



35
36
37
# File 'lib/danica/common.rb', line 35

def to_gnu(**options)
  to(:gnu, options)
end

#to_tex(**options) ⇒ Object



31
32
33
# File 'lib/danica/common.rb', line 31

def to_tex(**options)
  to(:tex, options)
end

#valued?Boolean

Returns:

  • (Boolean)


64
65
66
67
68
# File 'lib/danica/common.rb', line 64

def valued?
  to_f.present?
rescue Exception::NotDefined
  false
end