Class: TwitterCldr::Resources::Requirements::UnicodeRequirement

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter_cldr/resources/requirements/unicode_requirement.rb

Direct Known Subclasses

EmojiRequirement, UcaRequirement

Constant Summary collapse

UNICODE_URL =
"ftp://ftp.unicode.org/Public/%{version}".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version, files) ⇒ UnicodeRequirement

Returns a new instance of UnicodeRequirement.



18
19
20
21
# File 'lib/twitter_cldr/resources/requirements/unicode_requirement.rb', line 18

def initialize(version, files)
  @version = version
  @files = files
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



16
17
18
# File 'lib/twitter_cldr/resources/requirements/unicode_requirement.rb', line 16

def files
  @files
end

#versionObject (readonly)

Returns the value of attribute version.



16
17
18
# File 'lib/twitter_cldr/resources/requirements/unicode_requirement.rb', line 16

def version
  @version
end

Instance Method Details

#prepareObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/twitter_cldr/resources/requirements/unicode_requirement.rb', line 23

def prepare
  files.each do |file|
    unless File.file?(source_path_for(file))
      STDOUT.write("Downloading #{file} from unicode v#{version}... ")
      download(file)
      puts 'done'
    end

    puts "Using #{file} from unicode v#{version}"
  end
end

#source_path_for(file) ⇒ Object



35
36
37
# File 'lib/twitter_cldr/resources/requirements/unicode_requirement.rb', line 35

def source_path_for(file)
  File.join(TwitterCldr::VENDOR_DIR, "unicode_v#{version}", file)
end

#urlObject



39
40
41
# File 'lib/twitter_cldr/resources/requirements/unicode_requirement.rb', line 39

def url
  UNICODE_URL
end