Class: Syobocal::Comment::Element::Link
- Inherits:
-
Object
- Object
- Syobocal::Comment::Element::Link
- Defined in:
- lib/syobocal/comment/element/link.rb
Instance Attribute Summary collapse
-
#str ⇒ Object
readonly
Returns the value of attribute str.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(str, url) ⇒ Link
constructor
A new instance of Link.
Constructor Details
#initialize(str, url) ⇒ Link
Returns a new instance of Link.
7 8 9 |
# File 'lib/syobocal/comment/element/link.rb', line 7 def initialize(str, url) @str, @url = str, url end |
Instance Attribute Details
#str ⇒ Object (readonly)
Returns the value of attribute str.
5 6 7 |
# File 'lib/syobocal/comment/element/link.rb', line 5 def str @str end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/syobocal/comment/element/link.rb', line 5 def url @url end |
Class Method Details
.create(text) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/syobocal/comment/element/link.rb', line 15 def self.create(text) inner_str = text.match(/\A\[\[(.*)\]\]\Z/)[1] sep = inner_str.split(/ /) if ["http://", "https://", "archive://"].any? { |scheme| sep.last.start_with?(scheme) } link = sep.pop new(sep.join(" "), link) else new(sep.join(" "), nil) end end |
Instance Method Details
#==(other) ⇒ Object
11 12 13 |
# File 'lib/syobocal/comment/element/link.rb', line 11 def ==(other) other.instance_of?(self.class) && other.str == str && other.url == url end |