Class: Gemtext::Link
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Attributes inherited from Node
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #deconstruct_keys(*_keys) ⇒ Object
-
#initialize(content) ⇒ Link
constructor
A new instance of Link.
Methods inherited from Node
Constructor Details
#initialize(content) ⇒ Link
Returns a new instance of Link.
6 7 8 9 10 |
# File 'lib/gemtext/link.rb', line 6 def initialize(content) super content @target = @content.split(/\s+/).first @description = content.delete_prefix(@target).strip end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/gemtext/link.rb', line 3 def description @description end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
4 5 6 |
# File 'lib/gemtext/link.rb', line 4 def target @target end |
Class Method Details
.[](target, description = nil) ⇒ Object
12 13 14 |
# File 'lib/gemtext/link.rb', line 12 def self.[](target, description = nil) new "#{target} #{description}" end |
Instance Method Details
#==(other) ⇒ Object
16 17 18 |
# File 'lib/gemtext/link.rb', line 16 def ==(other) other.class == self.class && other.target == @target && other.description == @description end |
#deconstruct_keys(*_keys) ⇒ Object
20 21 22 |
# File 'lib/gemtext/link.rb', line 20 def deconstruct_keys(*_keys) { **super, target:, description: } end |