class Emot::CLI

Public Instance Methods

c(str, color=32) click to toggle source
# File lib/emot/cli.rb, line 57
def c(str, color=32)
  "\e[#{color}m#{str}\e[0m"
end
icons() click to toggle source
# File lib/emot/cli.rb, line 40
def icons
  CLI.start(['show', '--only', 'emoji', '--inline', options[:inline].to_s])
end
names() click to toggle source
# File lib/emot/cli.rb, line 46
def names
  CLI.start(['show', '--only', 'nameonly', '--inline', options[:inline].to_s])
end
show(name=nil) click to toggle source
# 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
version() click to toggle source
# File lib/emot/cli.rb, line 51
def version
  puts "Emot #{Emot::VERSION} (c) 2014 kyoendo"
end