Class: HatebuEntry::Command

Inherits:
Thor
  • Object
show all
Defined in:
lib/hatebu_entry/command.rb

Instance Method Summary collapse

Instance Method Details

#get(url) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/hatebu_entry/command.rb', line 7

def get(url)
  entries = HatebuEntry.new(url, options[:sort])
                       .entries(options[:pages].to_i)
  pretty_print begin
    options[:sort]=='count' ? entries.sort_by { |ent| -ent.count } : entries
  end
rescue
  abort "something go wrong."
end

#merge(*urls) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/hatebu_entry/command.rb', line 20

def merge(*urls)
  abort "At least 2 urls needed." if urls.size < 2
  entries = urls.map do |url|
    HatebuEntry.new(url, options[:sort]).entries options[:pages].to_i
  end
  merged = entries.inject {|mem, ent| HatebuEntry::Entry.merge(mem, ent) }
  pretty_print merged.sort_by { |ent| -ent.count }
end

#versionObject



30
31
32
# File 'lib/hatebu_entry/command.rb', line 30

def version
  puts "HatebuEntry #{HatebuEntry::VERSION} (c) 2013 kyoendo"
end