Class: Object

Inherits:
BasicObject
Defined in:
lib/rogc/formats/xml/base.rb,
lib/rogc/formats/xml/base.rb

Instance Method Summary collapse

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/rogc/formats/xml/base.rb', line 8

def blank?
  respond_to?(:empty?) ? empty? : !self
end

#to_boolObject

Raises:

  • (ArgumentError)


16
17
18
19
20
# File 'lib/rogc/formats/xml/base.rb', line 16

def to_bool
  return false if self == false || self.blank? || self.to_s =~ (/(false|f|no|n|0)$/i)
  return true if self == true || self.to_s =~ (/(true|t|yes|y|1)$/i)
  raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
end