Class: Goldfinger::Link

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(a) ⇒ Link

Returns a new instance of Link.



15
16
17
18
19
20
21
22
# File 'lib/goldfinger/link.rb', line 15

def initialize(a)
  @href       = a[:href]
  @template   = a[:template]
  @type       = a[:type]
  @rel        = a[:rel]
  @titles     = a[:titles]
  @properties = a[:properties]
end

Instance Attribute Details

#hrefString (readonly)

Returns The href the link points to.

Returns:

  • (String)

    The href the link points to



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/goldfinger/link.rb', line 12

class Link
  attr_reader :href, :template, :type, :rel

  def initialize(a)
    @href       = a[:href]
    @template   = a[:template]
    @type       = a[:type]
    @rel        = a[:rel]
    @titles     = a[:titles]
    @properties = a[:properties]
  end

  # The "titles" object comprises zero or more name/value pairs whose
  # names are a language tag or the string "und".  The string is
  # human-readable and describes the link relation.
  # @see #title
  # @return [Array] Array form of the hash
  def titles
    @titles.to_a
  end

  #  The "properties" object within the link relation object comprises
  # zero or more name/value pairs whose names are URIs (referred to as
  # "property identifiers") and whose values are strings or nil.
  # Properties are used to convey additional information about the link
  # relation.
  # @see #property
  # @return [Array] Array form of the hash
  def properties
    @properties.to_a
  end

  # Returns a title for a language
  # @param lang [String]
  # @return [String]
  def title(lang)
    @titles[lang]
  end

  # Returns a property for a key
  # @param key [String]
  # @return [String]
  def property(key)
    @properties[key]
  end
end

#relString (readonly)

Returns The relation descriptor of the link.

Returns:

  • (String)

    The relation descriptor of the link



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/goldfinger/link.rb', line 12

class Link
  attr_reader :href, :template, :type, :rel

  def initialize(a)
    @href       = a[:href]
    @template   = a[:template]
    @type       = a[:type]
    @rel        = a[:rel]
    @titles     = a[:titles]
    @properties = a[:properties]
  end

  # The "titles" object comprises zero or more name/value pairs whose
  # names are a language tag or the string "und".  The string is
  # human-readable and describes the link relation.
  # @see #title
  # @return [Array] Array form of the hash
  def titles
    @titles.to_a
  end

  #  The "properties" object within the link relation object comprises
  # zero or more name/value pairs whose names are URIs (referred to as
  # "property identifiers") and whose values are strings or nil.
  # Properties are used to convey additional information about the link
  # relation.
  # @see #property
  # @return [Array] Array form of the hash
  def properties
    @properties.to_a
  end

  # Returns a title for a language
  # @param lang [String]
  # @return [String]
  def title(lang)
    @titles[lang]
  end

  # Returns a property for a key
  # @param key [String]
  # @return [String]
  def property(key)
    @properties[key]
  end
end

#templateString (readonly)

Returns The template the link contains.

Returns:

  • (String)

    The template the link contains



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/goldfinger/link.rb', line 12

class Link
  attr_reader :href, :template, :type, :rel

  def initialize(a)
    @href       = a[:href]
    @template   = a[:template]
    @type       = a[:type]
    @rel        = a[:rel]
    @titles     = a[:titles]
    @properties = a[:properties]
  end

  # The "titles" object comprises zero or more name/value pairs whose
  # names are a language tag or the string "und".  The string is
  # human-readable and describes the link relation.
  # @see #title
  # @return [Array] Array form of the hash
  def titles
    @titles.to_a
  end

  #  The "properties" object within the link relation object comprises
  # zero or more name/value pairs whose names are URIs (referred to as
  # "property identifiers") and whose values are strings or nil.
  # Properties are used to convey additional information about the link
  # relation.
  # @see #property
  # @return [Array] Array form of the hash
  def properties
    @properties.to_a
  end

  # Returns a title for a language
  # @param lang [String]
  # @return [String]
  def title(lang)
    @titles[lang]
  end

  # Returns a property for a key
  # @param key [String]
  # @return [String]
  def property(key)
    @properties[key]
  end
end

#typeString (readonly)

Returns The mime type of the link.

Returns:

  • (String)

    The mime type of the link



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/goldfinger/link.rb', line 12

class Link
  attr_reader :href, :template, :type, :rel

  def initialize(a)
    @href       = a[:href]
    @template   = a[:template]
    @type       = a[:type]
    @rel        = a[:rel]
    @titles     = a[:titles]
    @properties = a[:properties]
  end

  # The "titles" object comprises zero or more name/value pairs whose
  # names are a language tag or the string "und".  The string is
  # human-readable and describes the link relation.
  # @see #title
  # @return [Array] Array form of the hash
  def titles
    @titles.to_a
  end

  #  The "properties" object within the link relation object comprises
  # zero or more name/value pairs whose names are URIs (referred to as
  # "property identifiers") and whose values are strings or nil.
  # Properties are used to convey additional information about the link
  # relation.
  # @see #property
  # @return [Array] Array form of the hash
  def properties
    @properties.to_a
  end

  # Returns a title for a language
  # @param lang [String]
  # @return [String]
  def title(lang)
    @titles[lang]
  end

  # Returns a property for a key
  # @param key [String]
  # @return [String]
  def property(key)
    @properties[key]
  end
end

Instance Method Details

#propertiesArray

The “properties” object within the link relation object comprises zero or more name/value pairs whose names are URIs (referred to as “property identifiers”) and whose values are strings or nil. Properties are used to convey additional information about the link relation.

Returns:

  • (Array)

    Array form of the hash

See Also:



40
41
42
# File 'lib/goldfinger/link.rb', line 40

def properties
  @properties.to_a
end

#property(key) ⇒ String

Returns a property for a key

Parameters:

  • key (String)

Returns:

  • (String)


54
55
56
# File 'lib/goldfinger/link.rb', line 54

def property(key)
  @properties[key]
end

#title(lang) ⇒ String

Returns a title for a language

Parameters:

  • lang (String)

Returns:

  • (String)


47
48
49
# File 'lib/goldfinger/link.rb', line 47

def title(lang)
  @titles[lang]
end

#titlesArray

The “titles” object comprises zero or more name/value pairs whose names are a language tag or the string “und”. The string is human-readable and describes the link relation.

Returns:

  • (Array)

    Array form of the hash

See Also:



29
30
31
# File 'lib/goldfinger/link.rb', line 29

def titles
  @titles.to_a
end