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.



130
131
132
# File 'lib/sisu/xhtml_epub2_concordance.rb', line 130

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

Instance Method Details

#htmlObject



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

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