Class: CBETA::CharFrequency
- Inherits:
-
Object
- Object
- CBETA::CharFrequency
- Defined in:
- lib/cbeta/char_freq.rb
Instance Method Summary collapse
- #char_freq(canon = nil) ⇒ Object
-
#initialize(xml_root, opts = {}) ⇒ CharFrequency
constructor
A new instance of CharFrequency.
Constructor Details
#initialize(xml_root, opts = {}) ⇒ CharFrequency
Returns a new instance of CharFrequency.
3 4 5 6 7 8 9 10 11 |
# File 'lib/cbeta/char_freq.rb', line 3 def initialize(xml_root, opts={}) @xml_root = xml_root @config = { top: 10 } @config.merge!(opts) @result = {} @current = @result end |
Instance Method Details
#char_freq(canon = nil) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/cbeta/char_freq.rb', line 13 def char_freq(canon=nil) stat_all if canon.nil? stat_canon(canon) r = @result.sort_by {|k,v| v} r[(0-@config[:top])..-1].reverse end |