class ZionData::Parser::Loopholes
Class for parsing Zion loopholes data
Attributes
node_pairs[R]
routes[R]
Public Class Methods
new(routes:, node_pairs:)
click to toggle source
# 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
Public Instance Methods
parse()
click to toggle source
# 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
Private Instance Methods
find_node_pair(node_pair_id)
click to toggle source
# File lib/zion_data/parser/loopholes.rb, line 25 def find_node_pair(node_pair_id) node_pairs.find { |np| np['id'] == node_pair_id } end