Sha256: eeeb38399739220ed71340be98448467148c784330a3a74b2763b8288394596a

Contents?: true

Size: 596 Bytes

Versions: 34

Compression:

Stored size: 596 Bytes

Contents

require 'devise'
require 'bootstrap-sass'
require 'font-awesome-sass-rails'
require 'constructor_core/engine'

class String
  def numeric?
    return true if self =~ /^\d+$/
    true if Float(self) rescue false
  end

  def boolean?
    if self =~ (/(true|yes)$/i) || self =~ (/(false|no)$/i)
      return true
    else
      return false
    end
  end

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

Version data entries

34 entries across 34 versions & 3 rubygems

Version Path
constructor-core-0.7.7 lib/constructor-core.rb
constructor-core-0.7.6 lib/constructor-core.rb
constructor-core-0.7.5 lib/constructor-core.rb
constructor-core-0.7.4 lib/constructor-core.rb
constructor-pages-0.7.3 core/lib/constructor-core.rb
constructor-core-0.7.3 core/lib/constructor-core.rb
constructor-cms-0.7.3 core/lib/constructor-core.rb
constructor-pages-0.7.2 core/lib/constructor-core.rb
constructor-core-0.7.2 core/lib/constructor-core.rb
constructor-cms-0.7.2 core/lib/constructor-core.rb
constructor-core-0.7.1 core/lib/constructor-core.rb
constructor-core-0.7.0 lib/constructor-core.rb
constructor-cms-0.7.0 core/lib/constructor-core.rb
constructor-core-0.6.4 lib/constructor-core.rb
constructor-cms-0.6.4 core/lib/constructor-core.rb
constructor-core-0.6.3 lib/constructor-core.rb
constructor-cms-0.6.3 core/lib/constructor-core.rb
constructor-core-0.6.2 lib/constructor-core.rb
constructor-cms-0.6.2 core/lib/constructor-core.rb
constructor-core-0.6.1 lib/constructor-core.rb