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.
- #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
12 13 14 15 16 17 18 |
# File 'lib/spellr/language.rb', line 12 def initialize(name, key: name[0], includes: [], hashbangs: [], locale: [], addable: true) # rubocop:disable Metrics/ParameterLists @name = name @key = key @includes = includes + hashbangs.map { |h| "#!:#{h}" } @locales = Array(locale) @addable = addable end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
10 11 12 |
# File 'lib/spellr/language.rb', line 10 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
20 21 22 |
# File 'lib/spellr/language.rb', line 20 def addable? @addable end |
#matches?(file) ⇒ Boolean
35 36 37 38 39 |
# File 'lib/spellr/language.rb', line 35 def matches?(file) return true if @includes.empty? fast_ignore.allowed?(file.to_s, directory: false, content: file.first_line) end |
#project_wordlist ⇒ Object
28 29 30 31 32 33 |
# File 'lib/spellr/language.rb', line 28 def project_wordlist @project_wordlist ||= Spellr::Wordlist.new( Spellr.pwd.join('.spellr_wordlists', "#{name}.txt"), name: name ) end |
#wordlists ⇒ Object
24 25 26 |
# File 'lib/spellr/language.rb', line 24 def wordlists default_wordlists.select(&:exist?) end |