Class: Gorails::Commands::Episodes

Inherits:
Gorails::Command
  • Object
show all
Defined in:
lib/gorails/commands/episodes.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.helpObject



20
21
22
# File 'lib/gorails/commands/episodes.rb', line 20

def self.help
  "View the latest GoRails episodes.\nUsage: {{command:#{Gorails::TOOL_NAME} episodes}}"
end

Instance Method Details

#call(_args, _name) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/gorails/commands/episodes.rb', line 8

def call(_args, _name)
  episodes = JSON.parse Net::HTTP.get(URI("https://gorails.com/episodes.json"))

  CLI::UI::Frame.open("Latest GoRails episodes") do
    episodes.each do |episode|
      puts CLI::UI.fmt "##{episode["number"]} {{green:#{episode["name"]}}}"
      puts episode["url"]
      puts
    end
  end
end