Module: NullAndVoid::Convertible
- Defined in:
- lib/null_and_void/convertible.rb
Instance Method Summary collapse
- #rationalize(*_args) ⇒ Object
- #to_a ⇒ Object (also: #to_ary)
- #to_c ⇒ Object
- #to_f ⇒ Object
- #to_hash ⇒ Object
- #to_html ⇒ Object
- #to_i ⇒ Object (also: #to_int)
- #to_json ⇒ Object
-
#to_model ⇒ Object
rubocop:disable Style/ExtraSpacing.
- #to_r ⇒ Object
- #to_s ⇒ Object
- #to_xml ⇒ Object
Instance Method Details
#rationalize(*_args) ⇒ Object
19 20 21 |
# File 'lib/null_and_void/convertible.rb', line 19 def rationalize(*_args) Rational(0) end |
#to_a ⇒ Object Also known as: to_ary
27 28 29 |
# File 'lib/null_and_void/convertible.rb', line 27 def to_a [] end |
#to_c ⇒ Object
9 10 11 |
# File 'lib/null_and_void/convertible.rb', line 9 def to_c Complex(0) end |
#to_f ⇒ Object
15 16 17 |
# File 'lib/null_and_void/convertible.rb', line 15 def to_f 0.0 end |
#to_hash ⇒ Object
33 34 35 |
# File 'lib/null_and_void/convertible.rb', line 33 def to_hash {} end |
#to_html ⇒ Object
37 38 39 |
# File 'lib/null_and_void/convertible.rb', line 37 def to_html '' end |
#to_i ⇒ Object Also known as: to_int
5 6 7 |
# File 'lib/null_and_void/convertible.rb', line 5 def to_i 0 end |
#to_json ⇒ Object
41 42 43 |
# File 'lib/null_and_void/convertible.rb', line 41 def to_json(*) 'null' end |
#to_model ⇒ Object
rubocop:disable Style/ExtraSpacing
54 55 56 57 58 59 60 61 |
# 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 ⇒ Object
23 24 25 |
# File 'lib/null_and_void/convertible.rb', line 23 def to_r Rational(0) end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/null_and_void/convertible.rb', line 49 def to_s '' end |
#to_xml ⇒ Object
45 46 47 |
# File 'lib/null_and_void/convertible.rb', line 45 def to_xml '' end |