class Deb822::Paragraph

Hash-like structure whose keys are FieldName.

Public Class Methods

new(hash = nil) click to toggle source
# File lib/deb822.rb, line 71
def initialize(hash = nil)
  @hash = {}
  update(hash) if hash
end

Public Instance Methods

[](key) click to toggle source
# File lib/deb822.rb, line 76
def [](key)
  @hash[Deb822::FieldName(key)]
end
[]=(key, value) click to toggle source
# File lib/deb822.rb, line 80
def []=(key, value)
  @hash[Deb822::FieldName(key)] = value.to_s
end
Also aliased as: store
fetch(key, *default, &block) click to toggle source
# File lib/deb822.rb, line 85
def fetch(key, *default, &block)
  @hash.fetch(Deb822::FieldName(key), *default, &block)
end
slice(*keys) click to toggle source
# File lib/deb822.rb, line 95
def slice(*keys)
  Paragraph.new(@hash.slice(*keys.map(&Deb822.method(:FieldName))))
end
store(key, value)
Alias for: []=
update(other) click to toggle source
# File lib/deb822.rb, line 89
def update(other)
  other.each do |k, v|
    store(k, v)
  end
end