class Parser

Attributes

json[R]
pattern[R]

Public Class Methods

new(path: nil, text: nil, pattern: '') click to toggle source

TODO: support path to file

# File lib/circle/art.rb, line 66
def initialize(path: nil, text: nil, pattern: '')
  if path
    text = File.read(path)
  end

  @json = JSON.parse(text)
  @pattern = pattern
end

Public Instance Methods

filenames() click to toggle source
# File lib/circle/art.rb, line 83
def filenames
  @filenames ||= urls.map.with_index do |e, index|
    "#{hashes[index]['node_index']}-" + e.split('/').last
  end
end
hashes() click to toggle source
# File lib/circle/art.rb, line 75
def hashes
  @hashes ||= @json.select {|e| e["url"].split('/').last.match(pattern)}
end
urls() click to toggle source
# File lib/circle/art.rb, line 79
def urls
  @urls ||= hashes.map{|e| e["url"]}
end