Module: Dictionaries::Statistics

Defined in:
lib/dictionaries/statistics/statistics.rb

Overview

Dictionaries::Statistics

Class Method Summary collapse

Class Method Details

.e(i = '') ⇒ Object

#

Dictionaries::Statistics.e

#


21
22
23
# File 'lib/dictionaries/statistics/statistics.rb', line 21

def self.e(i = '')
  puts i
end

.reportObject

#

Dictionaries::Statistics.report

#


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/dictionaries/statistics/statistics.rb', line 28

def self.report
  require 'yaml'
  begin
    require 'colours'
  rescue LoadError; end
  all_files = Dir[
    Dictionaries.project_yaml_dir?+'*'
  ].reject {|entry| entry.include?('deutsche_fremdwörter.yml') }
  e ::Colours.rev+'The statistics for each .yml file available in this project are'
  e 'as follows:'
  e
  all_files.each {|this_file|
    begin
      dataset = YAML.load_file(this_file)
      if dataset
        e "  #{File.basename(this_file).delete_suffix('.yml').ljust(15)} "+
          "#{::Colours.steelblue(dataset.keys.size.to_s.rjust(4))} words."
      else
        e 'No data is available for '+this_file+'.'
      end
    rescue => error
      pp error
    end
  }
  e
end