Sha256: 9ec2248357c529897026c4091fc1ff558a90cd42e03041cd7811930b9ee584f8

Contents?: true

Size: 551 Bytes

Versions: 4

Compression:

Stored size: 551 Bytes

Contents

require "#{File.dirname(__FILE__)}/hash/indifferent_access.rb"
class Hash
  def to_content_format
    fields = self.map do |key,value|
      unless value.nil?
        if key.to_s.match(/^cf_.+/)
          "CF-#{key.to_s[3..key.to_s.length].gsub(/_/, " ").camelize.humanize}: #{value}"
        else
          "#{key.to_s.camelize}: #{value}"
        end
      end
    end
    content = fields.compact.sort.join("\n")
  end

  def with_indifferent_access
    hash = HashWithIndifferentAccess.new(self)
    hash.default = self.default
    hash
  end

end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
axtro-roart-0.1.8 lib/roart/core/hash.rb
roart-0.1.8 lib/roart/core/hash.rb
roart-0.1.7 lib/roart/core/hash.rb
roart-0.1.6 lib/roart/core/hash.rb