Class: Fontisan::Parsers::Tag
- Inherits:
-
Object
- Object
- Fontisan::Parsers::Tag
- Defined in:
- lib/fontisan/parsers/tag.rb
Overview
Represents an OpenType tag (4-character identifier)
OpenType tags are four-byte identifiers used to identify tables, scripts, languages, and features. Tags are case-sensitive and padded with spaces if shorter than 4 characters.
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql?)
Compare tag with another tag or string.
-
#hash ⇒ Integer
Generate hash for use as Hash key.
-
#initialize(value) ⇒ Tag
constructor
Initialize a new Tag.
-
#to_s ⇒ String
Convert tag to string.
-
#valid? ⇒ Boolean
Check if tag is valid (exactly 4 characters).
Constructor Details
#initialize(value) ⇒ Tag
Initialize a new Tag
17 18 19 |
# File 'lib/fontisan/parsers/tag.rb', line 17 def initialize(value) @value = normalize_tag(value) end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
11 12 13 |
# File 'lib/fontisan/parsers/tag.rb', line 11 def value @value end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
Compare tag with another tag or string
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fontisan/parsers/tag.rb', line 32 def ==(other) case other when Tag @value == other.value when String @value == normalize_tag(other) else false end end |
#hash ⇒ Integer
Generate hash for use as Hash key
48 49 50 |
# File 'lib/fontisan/parsers/tag.rb', line 48 def hash @value.hash end |
#to_s ⇒ String
Convert tag to string
24 25 26 |
# File 'lib/fontisan/parsers/tag.rb', line 24 def to_s @value end |
#valid? ⇒ Boolean
Check if tag is valid (exactly 4 characters)
55 56 57 |
# File 'lib/fontisan/parsers/tag.rb', line 55 def valid? @value.length == 4 end |