Class: Analects::Library
- Inherits:
-
Object
- Object
- Analects::Library
- Defined in:
- lib/analects/library.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #cedict ⇒ Object
- #chise_ids ⇒ Object
- #data_dir ⇒ Object
- #hsk ⇒ Object
-
#initialize(options = {}) ⇒ Library
constructor
A new instance of Library.
- #sources ⇒ Object
- #unihan ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Library
Returns a new instance of Library.
11 12 13 |
# File 'lib/analects/library.rb', line 11 def initialize( = {}) @options = .freeze end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/analects/library.rb', line 9 def @options end |
Instance Method Details
#cedict ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/analects/library.rb', line 36 def cedict @cedict ||= create_source( :cedict, data_file: 'cedict_1_0_ts_utf-8_mdbg.txt', retrieval: [ :http, :gunzip, :save ] ) end |
#chise_ids ⇒ Object
44 45 46 47 48 49 |
# File 'lib/analects/library.rb', line 44 def chise_ids @chise_ids ||= create_source( :chise_ids, retrieval: :git ) end |
#data_dir ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/analects/library.rb', line 15 def data_dir if [:data_dir] Dir.mkdir([:data_dir]) unless File.exist?([:data_dir]) return [:data_dir] end File.join(Dir.home, '.analects').tap do |dir| unless File.exist? dir Dir.mkdir dir end end end |
#hsk ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/analects/library.rb', line 58 def hsk @hsk ||= create_source( :hsk, data_file: 'hsk.csv', retrieval: [ :http, :save ] ) end |
#sources ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/analects/library.rb', line 27 def sources [ cedict, chise_ids, unihan, hsk ] end |
#unihan ⇒ Object
51 52 53 54 55 56 |
# File 'lib/analects/library.rb', line 51 def unihan @unihan ||= create_source( :unihan, retrieval: [ :http, :unzip ] ) end |