Class: Mihari::Feed::Parser
- Inherits:
-
Object
- Object
- Mihari::Feed::Parser
- Defined in:
- lib/mihari/feed/parser.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(data) ⇒ Parser
constructor
A new instance of Parser.
-
#parse(selector) ⇒ Array<String>
Parse data by selector.
Constructor Details
#initialize(data) ⇒ Parser
Returns a new instance of Parser.
13 14 15 |
# File 'lib/mihari/feed/parser.rb', line 13 def initialize(data) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/mihari/feed/parser.rb', line 8 def data @data end |
Instance Method Details
#parse(selector) ⇒ Array<String>
Parse data by selector
24 25 26 27 28 29 30 31 |
# File 'lib/mihari/feed/parser.rb', line 24 def parse(selector) parsed = data.instance_eval(selector) raise FeedParseError unless parsed.is_a?(Array) || parsed.is_a?(Enumerator) raise FeedParseError unless parsed.all?(String) parsed.to_a end |