Sha256: c1251c0ee90461bfd031cbd0b9e4b38fca5c65943d4717332905a06b7e4d1235

Contents?: true

Size: 658 Bytes

Versions: 17

Compression:

Stored size: 658 Bytes

Contents

module RichTableComponent
  module CoreExtensions
    module String
      def to_bool
        return true if [:true, 'true', '1', 'yes', 'on', 't'].include? self
        return false if [:false, 'false', '0', 'no', 'off', 'f'].include? self
        return nil
      end
    end
  end
end

class String
  include RichTableComponent::CoreExtensions::String
end


module Enumerable
  def clean
    dup.clean!
  end

  def clean!
    reject! do |item|
      obj = is_a?(Hash) ? self[item] : item

      if obj.respond_to?(:reject!)
        obj.clean!
        obj.blank?
      else
        obj.blank? && !obj.is_a?(FalseClass)
      end
    end
    self
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rich_table_component-0.0.30 lib/rich_table_component/core_extensions/string.rb
rich_table_component-0.0.29 lib/rich_table_component/core_extensions/string.rb
rich_table_component-0.0.28 lib/rich_table_component/core_extensions/string.rb
rich_table_component-0.0.27 lib/rich_table_component/core_extensions/string.rb
rich_table_component-0.0.26 lib/rich_table_component/core_extensions/string.rb
rich_table_component-0.0.24 lib/rich_table_component/core_extensions/string.rb
rich_table_component-0.0.22 lib/rich_table_component/core_extensions/string.rb
rich_table_component-0.0.21 lib/rich_table_component/core_extensions/string.rb
rich_table_component-0.0.18 lib/rich_table_component/core_extensions/string.rb
rich_table_component-0.0.17 lib/rich_table_component/core_extensions/string.rb
rich_table_component-0.0.16 lib/rich_table_component/core_extensions/string.rb
rich_table_component-0.0.15 lib/rich_table_component/core_extensions/string.rb
rich_table_component-0.0.14 lib/rich_table_component/core_extensions/string.rb
rich_table_component-0.0.13 lib/rich_table_component/core_extensions/string.rb
rich_table_component-0.0.10 lib/rich_table_component/core_extensions/string.rb
rich_table_component-0.0.9 lib/rich_table_component/core_extensions/string.rb
rich_table_component-0.0.8 lib/rich_table_component/core_extensions/string.rb