Class: Emot::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/emot/cli.rb

Instance Method Summary collapse

Instance Method Details

#iconsObject



40
41
42
# File 'lib/emot/cli.rb', line 40

def icons
  CLI.start(['show', '--only', 'emoji', '--inline', options[:inline].to_s])
end

#namesObject



46
47
48
# File 'lib/emot/cli.rb', line 46

def names
  CLI.start(['show', '--only', 'nameonly', '--inline', options[:inline].to_s])
end

#show(name = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/emot/cli.rb', line 8

def show(name=nil)
  case name
  when nil, 'all'
    list =
      Emot.list.map do |name, (icon, code)|
        case options[:only]
        when 'name'
          "%s  %s" % [icon, c(name)]
        when 'code', 'unicode'
          "%s  %s" % [icon, code]
        when 'emoji', 'icon'
          "%s" % [icon]
        when 'nameonly'
          "%s" % [c(name)]
        else
          "%s  %s (%s)" % [icon ,c(name), code]
        end
      end
    puts (options[:inline] ? list.join("  ") : list)
    puts "\e[33m#{list.size}\e[0m #{c('emojis')}"
  else
    icon, code = Emot.list[name.intern]
    if icon
      print "%s  %s (%s)\n" % [icon, c(name), code]
    else
      puts "No emoji for '#{name}'"
    end
  end
end

#versionObject



51
52
53
# File 'lib/emot/cli.rb', line 51

def version
  puts "Emot #{Emot::VERSION} (c) 2014 kyoendo"
end