Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/dldinternet/thor/mixins/no_commands.rb

Instance Method Summary collapse

Instance Method Details

#class_fromObject Also known as: to_class



21
22
23
24
25
# File 'lib/dldinternet/thor/mixins/no_commands.rb', line 21

def class_from
  self.split('::').inject(Object) do |mod, class_name|
    mod.const_get(class_name)
  end
end

#to_boolObject Also known as: to_b

Raises:

  • (ArgumentError)


14
15
16
17
18
# File 'lib/dldinternet/thor/mixins/no_commands.rb', line 14

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