module NullAndVoid::Convertible

Public Instance Methods

rationalize(*_args) click to toggle source
# File lib/null_and_void/convertible.rb, line 19
def rationalize(*_args)
  Rational(0)
end
to_a() click to toggle source
# File lib/null_and_void/convertible.rb, line 27
def to_a
  []
end
Also aliased as: to_ary
to_ary()
Alias for: to_a
to_c() click to toggle source
# File lib/null_and_void/convertible.rb, line 9
def to_c
  Complex(0)
end
to_f() click to toggle source
# File lib/null_and_void/convertible.rb, line 15
def to_f
  0.0
end
to_hash() click to toggle source
# File lib/null_and_void/convertible.rb, line 33
def to_hash
  {}
end
to_html() click to toggle source
# File lib/null_and_void/convertible.rb, line 37
def to_html
  ''
end
to_i() click to toggle source
# File lib/null_and_void/convertible.rb, line 5
def to_i
  0
end
Also aliased as: to_int
to_int()
Alias for: to_i
to_json(*) click to toggle source
# File lib/null_and_void/convertible.rb, line 41
def to_json(*)
  'null'
end
to_model() click to toggle source

rubocop:disable Style/ExtraSpacing

# File lib/null_and_void/convertible.rb, line 54
def to_model
  base_path         = NullAndVoid::Inflections.demodulize(self.class.name)
  module_path       = NullAndVoid::Inflections.deconstantize(self.class.name)
  source_model      = base_path.gsub(/^Null/, '')
  source_model_path = "#{module_path}::#{source_model}"

  NullAndVoid::Inflections.constantize(source_model_path).new
end
to_r() click to toggle source
# File lib/null_and_void/convertible.rb, line 23
def to_r
  Rational(0)
end
to_s() click to toggle source
# File lib/null_and_void/convertible.rb, line 49
def to_s
  ''
end
to_xml() click to toggle source
# File lib/null_and_void/convertible.rb, line 45
def to_xml
  ''
end