2017-07-19 23:36:11 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-02-17 23:16:08 +01:00
|
|
|
module Goldfinger
|
|
|
|
# @!attribute [r] href
|
|
|
|
# @return [String] The href the link points to
|
2017-04-27 16:25:20 +02:00
|
|
|
# @!attribute [r] template
|
|
|
|
# @return [String] The template the link contains
|
2016-02-17 23:16:08 +01:00
|
|
|
# @!attribute [r] type
|
|
|
|
# @return [String] The mime type of the link
|
|
|
|
# @!attribute [r] rel
|
|
|
|
# @return [String] The relation descriptor of the link
|
|
|
|
class Link
|
2017-04-27 16:25:20 +02:00
|
|
|
attr_reader :href, :template, :type, :rel
|
2016-02-17 23:16:08 +01:00
|
|
|
|
|
|
|
def initialize(a)
|
|
|
|
@href = a[:href]
|
2017-04-27 16:25:20 +02:00
|
|
|
@template = a[:template]
|
2016-02-17 23:16:08 +01:00
|
|
|
@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
|
|
|
|
end
|