class Okao::CLI

Constants

OKAOS

Public Instance Methods

exec(okao = nil) click to toggle source
# File lib/okao/cli.rb, line 32
def exec(okao = nil)
  init_emoticon
  okao_text = load_file(options[:file_path])
  okao_text ||= okao

  code = okao_text.split("\n").reduce('') do |acc, cur|
    "#{acc}#{Okao::Parser.to_text(cur)}"
  end

  eval(code)
end
init_emoticon() click to toggle source
# File lib/okao/cli.rb, line 45
def init_emoticon
  Okao::Emoticon.init(okaos)
end
load_file(file_path) click to toggle source
# File lib/okao/cli.rb, line 53
def load_file(file_path)
  return if file_path.nil?
  File.open(file_path) do |file|
    file.read
  end
end
okaos() click to toggle source
# File lib/okao/cli.rb, line 49
def okaos
  OKAOS
end
to_okao(text = nil) click to toggle source
# File lib/okao/cli.rb, line 10
def to_okao(text = nil)
  init_emoticon
  normal_text = load_file(options[:file_path])
  normal_text ||= text

  okao_text = Okao::Parser.to_okao(normal_text)
  puts okao_text
end
to_text(okao = nil) click to toggle source
# File lib/okao/cli.rb, line 21
def to_text(okao = nil)
  init_emoticon
  okao_text = load_file(options[:file_path])
  okao_text ||= okao

  normal_text = Okao::Parser.to_text(okao_text)
  puts normal_text
end