Class: Spellr::Language
- Inherits:
-
Object
- Object
- Spellr::Language
- Defined in:
- lib/spellr/language.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #addable? ⇒ Boolean
-
#initialize(name, key: name[0], includes: [], hashbangs: [], locale: [], addable: true) ⇒ Language
constructor
rubocop:disable Metrics/ParameterLists, Metrics/MethodLength.
- #matches?(file) ⇒ Boolean
- #project_wordlist ⇒ Object
- #wordlists ⇒ Object
Constructor Details
#initialize(name, key: name[0], includes: [], hashbangs: [], locale: [], addable: true) ⇒ Language
rubocop:disable Metrics/ParameterLists, Metrics/MethodLength
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/spellr/language.rb', line 13 def initialize(name, key: name[0], includes: [], hashbangs: [], locale: [], addable: true) # rubocop:disable Metrics/ParameterLists, Metrics/MethodLength @name = name @key = key @includes = includes @hashbangs = hashbangs @hashbang_pattern = unless hashbangs.empty? /\A#!.*\b(?:#{hashbangs.map { |s| Regexp.escape(s) }.join('|')})\b/ end @locales = Array(locale) @addable = addable end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
11 12 13 |
# File 'lib/spellr/language.rb', line 11 def key @key end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/spellr/language.rb', line 10 def name @name end |
Instance Method Details
#addable? ⇒ Boolean
25 26 27 |
# File 'lib/spellr/language.rb', line 25 def addable? @addable end |
#matches?(file) ⇒ Boolean
29 30 31 |
# File 'lib/spellr/language.rb', line 29 def matches?(file) matches_includes?(file) || matches_hashbangs?(file) end |
#project_wordlist ⇒ Object
37 38 39 40 41 42 |
# File 'lib/spellr/language.rb', line 37 def project_wordlist @project_wordlist ||= Spellr::Wordlist.new( Spellr.pwd.join('.spellr_wordlists', "#{name}.txt"), name: name ) end |
#wordlists ⇒ Object
33 34 35 |
# File 'lib/spellr/language.rb', line 33 def wordlists default_wordlists.select(&:exist?) end |