Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/dldinternet/thor/mixins/no_commands.rb
Instance Method Summary collapse
- #class_from ⇒ Object (also: #to_class)
- #to_bool ⇒ Object (also: #to_b)
Instance Method Details
#class_from ⇒ Object 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_bool ⇒ Object Also known as: to_b
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 |