Module: HasHelpers::CoreExt::NilClass
- Defined in:
- lib/has_helpers/core_ext/nil_class.rb
Instance Method Summary collapse
- #to_bool ⇒ Object
-
#to_d ⇒ Object
Nil can be coerced to Integers and Floats, using
nil.to_iandnil.to_f, but not to BigDecimal usingnil.to_d(at least out of the box). - #to_renderable ⇒ Object
- #to_text_node(**options) ⇒ Object
Instance Method Details
#to_bool ⇒ Object
7 8 9 |
# File 'lib/has_helpers/core_ext/nil_class.rb', line 7 def to_bool false end |
#to_d ⇒ Object
Nil can be coerced to Integers and Floats, using nil.to_i and nil.to_f,
but not to BigDecimal using nil.to_d (at least out of the box).
14 15 16 |
# File 'lib/has_helpers/core_ext/nil_class.rb', line 14 def to_d BigDecimal(0) end |
#to_renderable ⇒ Object
19 20 21 |
# File 'lib/has_helpers/core_ext/nil_class.rb', line 19 def to_renderable to_text_node end |
#to_text_node(**options) ⇒ Object
23 24 25 |
# File 'lib/has_helpers/core_ext/nil_class.rb', line 23 def to_text_node(**) ::HasHelpers::TextNode.new("NIL", **) end |