Class: Fetcher::Microdata
- Inherits:
-
Object
- Object
- Fetcher::Microdata
- Includes:
- Discoverer::Writer, Virtus
- Defined in:
- lib/fetcher-microdata.rb,
lib/fetcher-microdata/review.rb,
lib/fetcher-microdata/version.rb,
lib/fetcher-microdata/person_user.rb,
lib/fetcher-microdata/article_small.rb,
lib/fetcher-microdata/user_comments.rb
Direct Known Subclasses
Defined Under Namespace
Classes: ArticleSmall, PersonUser, Review, UnknownSocialNetworkError, UserComments
Constant Summary collapse
- VERSION =
"0.0.13"
Instance Attribute Summary collapse
-
#_type ⇒ Object
readonly
Returns the value of attribute _type.
Instance Method Summary collapse
- #coerce(social_network, *raw_data) ⇒ Object
-
#initialize(*arguments) ⇒ Microdata
constructor
A new instance of Microdata.
Constructor Details
#initialize(*arguments) ⇒ Microdata
Returns a new instance of Microdata.
10 11 12 13 14 15 16 17 |
# File 'lib/fetcher-microdata.rb', line 10 def initialize *arguments if arguments.first.is_a? Symbol = arguments.shift self.attributes = coerce , *arguments elsif arguments.first.is_a? Hash self.attributes = arguments.first end end |
Instance Attribute Details
#_type ⇒ Object (readonly)
Returns the value of attribute _type.
8 9 10 |
# File 'lib/fetcher-microdata.rb', line 8 def _type @_type end |
Instance Method Details
#coerce(social_network, *raw_data) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fetcher-microdata.rb', line 19 def coerce , *raw_data begin eval("::#{self.class}::#{.to_s.capitalize}::Coercer").call *raw_data rescue NameError => e if e..include? "#{self.class}::#{.to_s.capitalize}" raise UnknownSocialNetworkError, "Couldn't find coertion algorithm for '#{}' social network, please require 'fetcher-microdata-#{}' in your project and make sure it has a #{self.class}::#{.to_s.capitalize}::Coercer" else raise e end end end |