Class: Chemicalml::Dictionary::Link

Inherits:
Object
  • Object
show all
Defined in:
lib/chemicalml/dictionary/link.rb

Overview

One external link from an entry's description or definition. Maps to the xhtml:a element in the original CML dictionary entries.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rel:, href:, title: nil) ⇒ Link

Returns a new instance of Link.



11
12
13
14
15
16
# File 'lib/chemicalml/dictionary/link.rb', line 11

def initialize(rel:, href:, title: nil)
  @rel = rel
  @href = href
  @title = title
  freeze
end

Instance Attribute Details

#hrefObject (readonly)

Returns the value of attribute href.



9
10
11
# File 'lib/chemicalml/dictionary/link.rb', line 9

def href
  @href
end

#relObject (readonly)

Returns the value of attribute rel.



9
10
11
# File 'lib/chemicalml/dictionary/link.rb', line 9

def rel
  @rel
end

#titleObject (readonly)

Returns the value of attribute title.



9
10
11
# File 'lib/chemicalml/dictionary/link.rb', line 9

def title
  @title
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


22
23
24
# File 'lib/chemicalml/dictionary/link.rb', line 22

def eql?(other)
  other.is_a?(Link) && to_h == other.to_h
end

#hashObject



27
28
29
# File 'lib/chemicalml/dictionary/link.rb', line 27

def hash
  to_h.hash
end

#to_hObject



18
19
20
# File 'lib/chemicalml/dictionary/link.rb', line 18

def to_h
  { rel: rel, href: href, title: title }.compact
end