Class: ZionData::Parser::Loopholes
- Inherits:
-
Object
- Object
- ZionData::Parser::Loopholes
- Includes:
- Helpers
- Defined in:
- lib/zion_data/parser/loopholes.rb
Overview
Class for parsing Zion loopholes data
Constant Summary
Constants included from Helpers
Instance Attribute Summary collapse
-
#node_pairs ⇒ Object
readonly
Returns the value of attribute node_pairs.
-
#routes ⇒ Object
readonly
Returns the value of attribute routes.
Instance Method Summary collapse
-
#initialize(routes:, node_pairs:) ⇒ Loopholes
constructor
A new instance of Loopholes.
- #parse ⇒ Object
Constructor Details
#initialize(routes:, node_pairs:) ⇒ Loopholes
Returns a new instance of Loopholes.
9 10 11 12 |
# File 'lib/zion_data/parser/loopholes.rb', line 9 def initialize(routes:, node_pairs:) @routes = JSON.parse(routes)['routes'] @node_pairs = JSON.parse(node_pairs)['node_pairs'] end |
Instance Attribute Details
#node_pairs ⇒ Object (readonly)
Returns the value of attribute node_pairs.
7 8 9 |
# File 'lib/zion_data/parser/loopholes.rb', line 7 def node_pairs @node_pairs end |
#routes ⇒ Object (readonly)
Returns the value of attribute routes.
7 8 9 |
# File 'lib/zion_data/parser/loopholes.rb', line 7 def routes @routes end |
Instance Method Details
#parse ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/zion_data/parser/loopholes.rb', line 14 def parse routes.each_with_object([]) do |route, result| node_pair = find_node_pair(route['node_pair_id']) next unless node_pair result << payload(node_pair['start_node'], node_pair['end_node'], route['start_time'], route['end_time']) end end |