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: []) ⇒ Language

Returns a new instance of Language.



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

def initialize(name, key: name[0], includes: [], hashbangs: [], locale: [])
  @name = name
  @key = key
  @includes = includes
  @hashbangs = hashbangs
  @locales = Array(locale)
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

#matches?(file) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#project_wordlistObject



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

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

#wordlistsObject



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

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