Skip to content

Instantly share code, notes, and snippets.

@cheebow
Created July 21, 2016 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cheebow/0a5262420cd8450a70507f8f33e62729 to your computer and use it in GitHub Desktop.
Save cheebow/0a5262420cd8450a70507f8f33e62729 to your computer and use it in GitHub Desktop.
TIF2016出演アイドル別に出演時間を表示する
require 'open-uri'
require 'json'
response = open('http://www.idolfes.com/2016/json/timetable/time.json')
data = response.read
json = JSON.parse(data)
artists = {}
json.keys.each{|day|
json[day].keys.each{|stage|
json[day][stage].each{|item|
item["day"] = day
item["stage"] = stage
if !artists[item["artist"]]
artists[item["artist"]] = []
end
artists[item["artist"]].push(item)
}
}
}
artists.keys.each{|artist|
puts "*" + artist
items = artists[artist]
items.each{|item|
puts "\t" + item["day"] + "[" + item["stage"] + "]" "(" + item["start"] + "-" + item["end"] + ")"
}
}
@iorionda
Copy link

https://gist.github.com/iorionda/39993c3998c79945ed61fdccd83250dc

require 'open-uri'
require 'json'

response = open('http://www.idolfes.com/2016/json/timetable/time.json')
data = JSON.parse(response.read)

artists = {}
data.each do |day, stages|
  stages.each do |stage, items|
    items.each do |item|
      (artists[item["artist"]] ||= []) << item.merge(
        'day'   => day,
        'stage' => stage
      )
    end 
  end 
end

artists.keys.each do |artist|
  puts "*#{artist}"
  items = artists[artist]
  items.each do |item|
    puts "\t#{item['day']}[#{item['stage']}](#{item['start']}-#{item['end']})"
  end 
end

こんな感じですかねえ。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment