Module: NPR::Concern::LinksAssociation
- Included in:
- Entity::Byline, Entity::List, Entity::Parent, Entity::RelatedLink, Entity::Story
- Defined in:
- lib/npr/concern/links_association.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#link_for(type) ⇒ Object
————————- Find links of the passed in type.
Class Method Details
Instance Method Details
#link_for(type) ⇒ Object
Find links of the passed in type.
Example:
story.link_for("html") #=> http://npr.org/...
story.link_for("nothing") #=> nil
Returns an the content of that link if found, or nil if not found.
19 20 21 22 23 |
# File 'lib/npr/concern/links_association.rb', line 19 def link_for(type) if link = self.links.find { |link| link.type == type } link.to_s end end |