Class: SiSU_XHTML_EPUB2_Concordance::Source::Word

Inherits:
Object
  • Object
show all
Defined in:
lib/sisu/xhtml_epub2_concordance.rb

Constant Summary collapse

@@word_previous =
''

Instance Method Summary collapse

Constructor Details

#initialize(word, freq) ⇒ Word

Returns a new instance of Word.



132
133
134
# File 'lib/sisu/xhtml_epub2_concordance.rb', line 132

def initialize(word,freq)
  @word,@freq=word,freq
end

Instance Method Details

#htmlObject



135
136
137
138
139
140
141
142
143
# File 'lib/sisu/xhtml_epub2_concordance.rb', line 135

def html
  w=if @word.capitalize==@@word_previous
    %{\n<p class="concordance_word">#{@word}</p><p class="concordance_count">(#{@freq})</p>\n\t<p class="concordance_object"> }
  else n=@word.strip.gsub(/\s+/,'_') #also need to convert extended character set to html
    %{\n<p class="concordance_word"><a name="#{n}">#{@word}</a></p><p class="concordance_count">(#{@freq})</p>\n\t<p class="concordance_object"> }
  end
  @@word_previous=@word.capitalize
  w
end