Class: Paragraph::Markup
- Inherits:
-
Object
- Object
- Paragraph::Markup
- Defined in:
- lib/Models/Paragraph.rb
Constant Summary collapse
- SEMANTIC_KEYS =
Semantic identity fields used for ‘==` / `eql?` / `hash`. `start` and `end` are interval coordinates (handled by Rangeable as the [lo, hi] pair) rather than identity. `linkMetadata` is currently unused downstream so it is excluded too. This identity is what lets Rangeable merge two Markups that describe the same logical span (e.g. two STRONG runs that overlap) into a single coalesced interval.
[:type, :href, :anchorType, :userId].freeze
Instance Attribute Summary collapse
-
#anchorType ⇒ Object
Returns the value of attribute anchorType.
-
#end ⇒ Object
Returns the value of attribute end.
-
#href ⇒ Object
Returns the value of attribute href.
-
#linkMetadata ⇒ Object
Returns the value of attribute linkMetadata.
-
#start ⇒ Object
Returns the value of attribute start.
-
#type ⇒ Object
Returns the value of attribute type.
-
#userId ⇒ Object
Returns the value of attribute userId.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(json) ⇒ Markup
constructor
A new instance of Markup.
Constructor Details
#initialize(json) ⇒ Markup
Returns a new instance of Markup.
31 32 33 34 35 36 37 38 39 |
# File 'lib/Models/Paragraph.rb', line 31 def initialize(json) @type = json['type'] @start = json['start'] @end = json['end'] @href = json['href'] @anchorType = json['anchorType'] @userId = json['userId'] @linkMetadata = json['linkMetadata'] end |
Instance Attribute Details
#anchorType ⇒ Object
Returns the value of attribute anchorType.
20 21 22 |
# File 'lib/Models/Paragraph.rb', line 20 def anchorType @anchorType end |
#end ⇒ Object
Returns the value of attribute end.
20 21 22 |
# File 'lib/Models/Paragraph.rb', line 20 def end @end end |
#href ⇒ Object
Returns the value of attribute href.
20 21 22 |
# File 'lib/Models/Paragraph.rb', line 20 def href @href end |
#linkMetadata ⇒ Object
Returns the value of attribute linkMetadata.
20 21 22 |
# File 'lib/Models/Paragraph.rb', line 20 def linkMetadata @linkMetadata end |
#start ⇒ Object
Returns the value of attribute start.
20 21 22 |
# File 'lib/Models/Paragraph.rb', line 20 def start @start end |
#type ⇒ Object
Returns the value of attribute type.
20 21 22 |
# File 'lib/Models/Paragraph.rb', line 20 def type @type end |
#userId ⇒ Object
Returns the value of attribute userId.
20 21 22 |
# File 'lib/Models/Paragraph.rb', line 20 def userId @userId end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
41 42 43 44 |
# File 'lib/Models/Paragraph.rb', line 41 def ==(other) return false unless other.is_a?(Markup) SEMANTIC_KEYS.all? { |k| public_send(k) == other.public_send(k) } end |
#hash ⇒ Object
47 48 49 |
# File 'lib/Models/Paragraph.rb', line 47 def hash SEMANTIC_KEYS.map { |k| public_send(k) }.hash end |