Class: Accord::Tags
- Inherits:
-
Object
- Object
- Accord::Tags
- Defined in:
- lib/accord/tags.rb
Class Method Summary collapse
Instance Method Summary collapse
- #[](tag) ⇒ Object
- #[]=(tag, value) ⇒ Object
- #fetch(tag, default = Tags.marker) ⇒ Object
-
#initialize ⇒ Tags
constructor
A new instance of Tags.
Constructor Details
#initialize ⇒ Tags
Returns a new instance of Tags.
3 4 5 |
# File 'lib/accord/tags.rb', line 3 def initialize @hash = {} end |
Class Method Details
.marker ⇒ Object
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
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 |