Class: LinguistsFieldGuide::Language

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

Overview

Language names that are recognizable by GitHub.

This is a trimmed-down version of [‘github-linguist`’s](rubygems.org/gems/github-linguist) [‘Linguist::Language`](www.rubydoc.info/gems/github-linguist/Linguist/Language) class, with just enough information to use for reference.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Language

Internal: Applies all the given attributes to instance variables.



59
60
61
62
63
# File 'lib/linguists_field_guide.rb', line 59

def initialize(attributes)
  attributes.each do |key, value|
    instance_variable_set(key, value)
  end
end

Instance Attribute Details

#ace_modeObject (readonly)

See [github-linguist’s documentation of ‘ace_mode`](www.rubydoc.info/gems/github-linguist/Linguist/Language#ace_mode-instance_method)



29
30
31
# File 'lib/linguists_field_guide.rb', line 29

def ace_mode
  @ace_mode
end

#aliasesObject (readonly)

See [github-linguist’s documentation of ‘aliases`](www.rubydoc.info/gems/github-linguist/Linguist/Language#aliases-instance_method)



25
26
27
# File 'lib/linguists_field_guide.rb', line 25

def aliases
  @aliases
end

#codemirror_mime_typeObject (readonly)

See [github-linguist’s documentation of ‘codemirror_mime_type`](www.rubydoc.info/gems/github-linguist/Linguist/Language#codemirror_mime_type-instance_method)



33
34
35
# File 'lib/linguists_field_guide.rb', line 33

def codemirror_mime_type
  @codemirror_mime_type
end

#codemirror_modeObject (readonly)

See [github-linguist’s documentation of ‘codemirror_mode`](www.rubydoc.info/gems/github-linguist/Linguist/Language#codemirror_mode-instance_method)



31
32
33
# File 'lib/linguists_field_guide.rb', line 31

def codemirror_mode
  @codemirror_mode
end

#colorObject (readonly)

See [github-linguist’s documentation of ‘color`](www.rubydoc.info/gems/github-linguist/Linguist/Language#color-instance_method)



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

def color
  @color
end

#extensionsObject (readonly)

See [github-linguist’s documentation of ‘extensions`](www.rubydoc.info/gems/github-linguist/Linguist/Language#extensions-instance_method)



39
40
41
# File 'lib/linguists_field_guide.rb', line 39

def extensions
  @extensions
end

#filenamesObject (readonly)

See [github-linguist’s documentation of ‘filenames`](www.rubydoc.info/gems/github-linguist/Linguist/Language#filenames-instance_method)



43
44
45
# File 'lib/linguists_field_guide.rb', line 43

def filenames
  @filenames
end

#fs_nameObject (readonly)

See [github-linguist’s documentation of ‘fs_name`](www.rubydoc.info/gems/github-linguist/Linguist/Language#fs_name-instance_method)



21
22
23
# File 'lib/linguists_field_guide.rb', line 21

def fs_name
  @fs_name
end

#interpretersObject (readonly)

See [github-linguist’s documentation of ‘interpreters`](www.rubydoc.info/gems/github-linguist/Linguist/Language#interpreters-instance_method)



41
42
43
# File 'lib/linguists_field_guide.rb', line 41

def interpreters
  @interpreters
end

#language_idObject (readonly)

See [github-linguist’s documentation of ‘language_id`](www.rubydoc.info/gems/github-linguist/Linguist/Language#language_id-instance_method)



37
38
39
# File 'lib/linguists_field_guide.rb', line 37

def language_id
  @language_id
end

#nameObject (readonly)

See [github-linguist’s documentation of ‘name`](www.rubydoc.info/gems/github-linguist/Linguist/Language#name-instance_method)



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

def name
  @name
end

#tm_scopeObject (readonly)

See [github-linguist’s documentation of ‘tm_scope`](www.rubydoc.info/gems/github-linguist/Linguist/Language#tm_scope-instance_method)



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

def tm_scope
  @tm_scope
end

#wrapObject (readonly)

See [github-linguist’s documentation of ‘wrap`](www.rubydoc.info/gems/github-linguist/Linguist/Language#wrap-instance_method)



35
36
37
# File 'lib/linguists_field_guide.rb', line 35

def wrap
  @wrap
end

Class Method Details

.allArray<Language>

Returns:



66
67
68
# File 'lib/linguists_field_guide.rb', line 66

def self.all
  @languages
end

.create(attributes) ⇒ Object

Internal: Creates a Language object, applies all the given attributes to instance variables, and adds it to the ‘#all` list.



49
50
51
52
53
54
55
# File 'lib/linguists_field_guide.rb', line 49

def self.create(attributes)
  language = new(attributes)

  @languages << language

  @index[language.name.downcase] = @name_index[language.name.downcase] = language
end

.find_by_name(name) ⇒ Object

Look up Language by its proper name.

Parameters:

  • name (String)

    The proper name of a Language



73
74
75
# File 'lib/linguists_field_guide.rb', line 73

def self.find_by_name(name)
  @name_index[name&.downcase]
end

Instance Method Details

#groupLanguage

Get Language group

Returns:



80
81
82
83
84
85
86
# File 'lib/linguists_field_guide.rb', line 80

def group
  @group ||= if @group_name.nil?
               self
             else
               Language.find_by_name(@group_name)
             end
end

#popular?Boolean

Is it popular?

Returns:

  • (Boolean)


97
98
99
# File 'lib/linguists_field_guide.rb', line 97

def popular?
  @popular
end

#searchable?Boolean

Is it searchable?

Returns:

  • (Boolean)


102
103
104
# File 'lib/linguists_field_guide.rb', line 102

def searchable?
  @searchable
end

#typeSymbol

Get type.

Returns:



92
93
94
# File 'lib/linguists_field_guide.rb', line 92

def type
  @type.to_sym
end