Class: HatenaKeywordHaiku::Word

Inherits:
Object
  • Object
show all
Defined in:
lib/plugins/hatena_keyword_haiku.rb

Instance Method Summary collapse

Constructor Details

#initialize(word, yomi) ⇒ Word

Returns a new instance of Word.


7
8
9
10
11
# File 'lib/plugins/hatena_keyword_haiku.rb', line 7

def initialize(word, yomi)
  raise 'word is nil' unless word and not word.empty?
  @word = word
  @yomi = yomi
end

Instance Method Details

#lengthObject


21
22
23
# File 'lib/plugins/hatena_keyword_haiku.rb', line 21

def length
  @length ||= self.yomi.gsub(/\n|ぁ|ぃ|ぅ|ぇ|ぉ|ァ|ィ|ゥ|ェ|ォ|ゃ|ゅ|ょ|ャ|ュ|ョ/, '').split(//).length
end

#wordObject


13
14
15
# File 'lib/plugins/hatena_keyword_haiku.rb', line 13

def word
  @word
end

#yomiObject


17
18
19
# File 'lib/plugins/hatena_keyword_haiku.rb', line 17

def yomi
  @yomi
end