Class: Spellr::Language

Inherits:
Object
  • Object
show all
Defined in:
lib/spellr/language.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, key: name[0], includes: [], hashbangs: [], locale: [], addable: true) ⇒ Language

rubocop:disable Metrics/ParameterLists, Metrics/MethodLength



10
11
12
13
14
15
16
17
# File 'lib/spellr/language.rb', line 10

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
  @locales = Array(locale)
  @addable = addable
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



8
9
10
# File 'lib/spellr/language.rb', line 8

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/spellr/language.rb', line 7

def name
  @name
end

Instance Method Details

#addable?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/spellr/language.rb', line 19

def addable?
  @addable
end

#matches?(file) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/spellr/language.rb', line 23

def matches?(file)
  matches_includes?(file) || matches_hashbangs?(file)
end

#project_wordlistObject



31
32
33
34
35
36
# File 'lib/spellr/language.rb', line 31

def project_wordlist
  @project_wordlist ||= Spellr::Wordlist.new(
    Pathname.pwd.join('.spellr_wordlists', "#{name}.txt"),
    name: name
  )
end

#wordlistsObject



27
28
29
# File 'lib/spellr/language.rb', line 27

def wordlists
  default_wordlists.select(&:exist?)
end