Class: Yoda::Store::Objects::Tag
- Inherits:
-
Object
- Object
- Yoda::Store::Objects::Tag
- Defined in:
- lib/yoda/store/objects/tag.rb
Instance Attribute Summary collapse
- #lexical_scope ⇒ Array<String> readonly
- #name ⇒ String? readonly
- #tag_name ⇒ String readonly
- #text ⇒ String? readonly
- #yard_types ⇒ Array<String> readonly
Class Method Summary collapse
Instance Method Summary collapse
- #==(another) ⇒ Object
- #eql?(another) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(tag_name:, name: nil, yard_types: [], text: nil, lexical_scope: []) ⇒ Tag
constructor
A new instance of Tag.
- #to_h ⇒ Hash
- #to_json(_state = nil) ⇒ String
Constructor Details
#initialize(tag_name:, name: nil, yard_types: [], text: nil, lexical_scope: []) ⇒ Tag
Returns a new instance of Tag.
30 31 32 33 34 35 36 |
# File 'lib/yoda/store/objects/tag.rb', line 30 def initialize(tag_name:, name: nil, yard_types: [], text: nil, lexical_scope: []) @tag_name = tag_name @name = name @yard_types = yard_types @text = text @lexical_scope = lexical_scope end |
Instance Attribute Details
#lexical_scope ⇒ Array<String> (readonly)
23 24 25 |
# File 'lib/yoda/store/objects/tag.rb', line 23 def lexical_scope @lexical_scope end |
#name ⇒ String? (readonly)
20 21 22 |
# File 'lib/yoda/store/objects/tag.rb', line 20 def name @name end |
#tag_name ⇒ String (readonly)
17 18 19 |
# File 'lib/yoda/store/objects/tag.rb', line 17 def tag_name @tag_name end |
#text ⇒ String? (readonly)
20 21 22 |
# File 'lib/yoda/store/objects/tag.rb', line 20 def text @text end |
#yard_types ⇒ Array<String> (readonly)
23 24 25 |
# File 'lib/yoda/store/objects/tag.rb', line 23 def yard_types @yard_types end |
Class Method Details
.json_creatable? ⇒ Boolean
6 7 8 |
# File 'lib/yoda/store/objects/tag.rb', line 6 def json_creatable? true end |
.json_create(params) ⇒ Object
11 12 13 |
# File 'lib/yoda/store/objects/tag.rb', line 11 def json_create(params) new(params.map { |k, v| [k.to_sym, v] }.select { |(k, v)| %i(tag_name name yard_types text lexical_scope).include?(k) }.to_h) end |
Instance Method Details
#==(another) ⇒ Object
51 52 53 |
# File 'lib/yoda/store/objects/tag.rb', line 51 def ==(another) eql?(another) end |
#eql?(another) ⇒ Boolean
47 48 49 |
# File 'lib/yoda/store/objects/tag.rb', line 47 def eql?(another) self.class == another.class && to_h == another.to_h end |
#hash ⇒ Object
43 44 45 |
# File 'lib/yoda/store/objects/tag.rb', line 43 def hash ([self.class.name] + to_h.to_a).hash end |
#to_h ⇒ Hash
39 40 41 |
# File 'lib/yoda/store/objects/tag.rb', line 39 def to_h { name: name, tag_name: tag_name, yard_types: yard_types, text: text, lexical_scope: lexical_scope } end |
#to_json(_state = nil) ⇒ String
56 57 58 |
# File 'lib/yoda/store/objects/tag.rb', line 56 def to_json(_state = nil) to_h.merge(json_class: self.class.name).to_json end |