Module: Zidian

Defined in:
lib/zidian.rb

Defined Under Namespace

Classes: InvalFindInputException, InvalidIdException, Word

Class Method Summary collapse

Class Method Details

.find(expression) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/zidian.rb', line 3

def self.find(expression)
  $KCODE = 'UTF8' if RUBY_VERSION < "1.9.0"
  case expression.class.name
  when "Array"
    expression.collect{|e| find(e) }.flatten.uniq
  when "Integer", "Fixnum" then
    Word.new(get_line(expression), expression)
  when "String" then
    find_words(expression).collect{|raw_word| Word.new(raw_word) }
  else
    raise InvalFindInputException
  end
end