Class: Goldfinger::Link
- Inherits:
-
Object
- Object
- Goldfinger::Link
- Defined in:
- lib/goldfinger/link.rb
Instance Attribute Summary collapse
-
#href ⇒ String
readonly
The href the link points to.
-
#rel ⇒ String
readonly
The relation descriptor of the link.
-
#template ⇒ String
readonly
The template the link contains.
-
#type ⇒ String
readonly
The mime type of the link.
Instance Method Summary collapse
-
#initialize(a) ⇒ Link
constructor
A new instance of Link.
-
#properties ⇒ Array
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.
-
#property(key) ⇒ String
Returns a property for a key.
-
#title(lang) ⇒ String
Returns a title for a language.
-
#titles ⇒ Array
The “titles” object comprises zero or more name/value pairs whose names are a language tag or the string “und”.
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
#href ⇒ String (readonly)
Returns 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 |
#rel ⇒ String (readonly)
Returns 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 |
#template ⇒ String (readonly)
Returns 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 |
#type ⇒ String (readonly)
Returns 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
#properties ⇒ Array
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.
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
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
47 48 49 |
# File 'lib/goldfinger/link.rb', line 47 def title(lang) @titles[lang] end |
#titles ⇒ Array
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.
29 30 31 |
# File 'lib/goldfinger/link.rb', line 29 def titles @titles.to_a end |