Module: HasHelpers::CoreExt::NilClass

Defined in:
lib/has_helpers/core_ext/nil_class.rb

Instance Method Summary collapse

Instance Method Details

#to_boolObject



7
8
9
# File 'lib/has_helpers/core_ext/nil_class.rb', line 7

def to_bool
  false
end

#to_dObject

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_renderableObject



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(**options)
  ::HasHelpers::TextNode.new("NIL", **options)
end