Class: MARC::Spec::Queries::Tag
- Inherits:
-
Object
- Object
- MARC::Spec::Queries::Tag
- Includes:
- Applicable
- Defined in:
- lib/marc/spec/queries/tag.rb
Constant Summary collapse
- LDR =
Constants
'LDR'.freeze
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
———————————————————— Attributes.
-
#tag_exact ⇒ Object
readonly
———————————————————— Attributes.
-
#tag_re ⇒ Object
readonly
———————————————————— Attributes.
Instance Method Summary collapse
-
#initialize(tag, index = nil) ⇒ Tag
constructor
———————————————————— Initializer.
-
#leader? ⇒ Boolean
———————————————————— Public methods.
-
#to_s ⇒ Object
———————————————————— Object overrides.
Methods included from Applicable
Methods included from Part
Constructor Details
#initialize(tag, index = nil) ⇒ Tag
Initializer
23 24 25 26 27 28 |
# File 'lib/marc/spec/queries/tag.rb', line 23 def initialize(tag, index = nil) raise ArgumentError, 'Tag cannot be nil' unless tag @tag_exact = tag.to_s unless (@tag_re = tag_re_from(tag)) @index = ensure_type(index, PositionOrRange, allow_nil: true) end |
Instance Attribute Details
#index ⇒ Object (readonly)
Attributes
18 19 20 |
# File 'lib/marc/spec/queries/tag.rb', line 18 def index @index end |
#tag_exact ⇒ Object (readonly)
Attributes
18 19 20 |
# File 'lib/marc/spec/queries/tag.rb', line 18 def tag_exact @tag_exact end |
#tag_re ⇒ Object (readonly)
Attributes
18 19 20 |
# File 'lib/marc/spec/queries/tag.rb', line 18 def tag_re @tag_re end |
Instance Method Details
#leader? ⇒ Boolean
Public methods
33 34 35 |
# File 'lib/marc/spec/queries/tag.rb', line 33 def leader? tag_exact == LDR end |
#to_s ⇒ Object
Object overrides
40 41 42 43 44 45 |
# File 'lib/marc/spec/queries/tag.rb', line 40 def to_s StringIO.new.tap do |out| out << tag_str out << "[#{index}]" if index end.string end |