Class: Sawyer::LinkParsers::Simple
- Inherits:
-
Object
- Object
- Sawyer::LinkParsers::Simple
- Defined in:
- lib/sawyer/link_parsers/simple.rb
Constant Summary collapse
- LINK_REGEX =
/_?url$/
Instance Method Summary collapse
-
#parse(data) ⇒ Object
Public: Parses simple *_url style links on resources.
Instance Method Details
#parse(data) ⇒ Object
Public: Parses simple *_url style links on resources
data - Hash of resource data
Returns a Hash of data with separate links Hash
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sawyer/link_parsers/simple.rb', line 14 def parse(data) links = {} inline_links = data.keys.select {|k| k.to_s[LINK_REGEX] } inline_links.each do |key| rel_name = key.to_s == 'url' ? 'self' : key.to_s.gsub(LINK_REGEX, '') links[rel_name.to_sym] = data[key] end return data, links end |