Class: Accord::Tags

Inherits:
Object
  • Object
show all
Defined in:
lib/accord/tags.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTags

Returns a new instance of Tags.



3
4
5
# File 'lib/accord/tags.rb', line 3

def initialize
  @hash = {}
end

Class Method Details

.markerObject



21
22
23
# File 'lib/accord/tags.rb', line 21

def self.marker
  @marker ||= Object.new
end

Instance Method Details

#[](tag) ⇒ Object



11
12
13
# File 'lib/accord/tags.rb', line 11

def [](tag)
  @hash[tag.to_sym]
end

#[]=(tag, value) ⇒ Object



7
8
9
# File 'lib/accord/tags.rb', line 7

def []=(tag, value)
  @hash[tag.to_sym] = value
end

#fetch(tag, default = Tags.marker) ⇒ Object

Raises:

  • (ArgumentError)


15
16
17
18
19
# File 'lib/accord/tags.rb', line 15

def fetch(tag, default=Tags.marker)
  return @hash[tag] if @hash.has_key?(tag)
  return default unless default.equal?(self.class.marker)
  raise ArgumentError, "tag #{tag.inspect} not found."
end