class Syobocal::Comment::Element::Link

Attributes

str[R]
url[R]

Public Class Methods

create(text) click to toggle source
# 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
new(str, url) click to toggle source
# File lib/syobocal/comment/element/link.rb, line 7
def initialize(str, url)
  @str, @url = str, url
end

Public Instance Methods

==(other) click to toggle source
# File lib/syobocal/comment/element/link.rb, line 11
def ==(other)
  other.instance_of?(self.class) && other.str == str && other.url == url
end