Class: LinguistsFieldGuide::Language
- Inherits:
-
Object
- Object
- LinguistsFieldGuide::Language
- 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
-
#ace_mode ⇒ Object
readonly
See [github-linguist’s documentation of ‘ace_mode`](www.rubydoc.info/gems/github-linguist/Linguist/Language#ace_mode-instance_method).
-
#aliases ⇒ Object
readonly
See [github-linguist’s documentation of ‘aliases`](www.rubydoc.info/gems/github-linguist/Linguist/Language#aliases-instance_method).
-
#codemirror_mime_type ⇒ Object
readonly
See [github-linguist’s documentation of ‘codemirror_mime_type`](www.rubydoc.info/gems/github-linguist/Linguist/Language#codemirror_mime_type-instance_method).
-
#codemirror_mode ⇒ Object
readonly
See [github-linguist’s documentation of ‘codemirror_mode`](www.rubydoc.info/gems/github-linguist/Linguist/Language#codemirror_mode-instance_method).
-
#color ⇒ Object
readonly
See [github-linguist’s documentation of ‘color`](www.rubydoc.info/gems/github-linguist/Linguist/Language#color-instance_method).
-
#extensions ⇒ Object
readonly
See [github-linguist’s documentation of ‘extensions`](www.rubydoc.info/gems/github-linguist/Linguist/Language#extensions-instance_method).
-
#filenames ⇒ Object
readonly
See [github-linguist’s documentation of ‘filenames`](www.rubydoc.info/gems/github-linguist/Linguist/Language#filenames-instance_method).
-
#fs_name ⇒ Object
readonly
See [github-linguist’s documentation of ‘fs_name`](www.rubydoc.info/gems/github-linguist/Linguist/Language#fs_name-instance_method).
-
#interpreters ⇒ Object
readonly
See [github-linguist’s documentation of ‘interpreters`](www.rubydoc.info/gems/github-linguist/Linguist/Language#interpreters-instance_method).
-
#language_id ⇒ Object
readonly
See [github-linguist’s documentation of ‘language_id`](www.rubydoc.info/gems/github-linguist/Linguist/Language#language_id-instance_method).
-
#name ⇒ Object
readonly
See [github-linguist’s documentation of ‘name`](www.rubydoc.info/gems/github-linguist/Linguist/Language#name-instance_method).
-
#tm_scope ⇒ Object
readonly
See [github-linguist’s documentation of ‘tm_scope`](www.rubydoc.info/gems/github-linguist/Linguist/Language#tm_scope-instance_method).
-
#wrap ⇒ Object
readonly
See [github-linguist’s documentation of ‘wrap`](www.rubydoc.info/gems/github-linguist/Linguist/Language#wrap-instance_method).
Class Method Summary collapse
- .all ⇒ Array<Language>
-
.create(attributes) ⇒ Object
Internal: Creates a Language object, applies all the given attributes to instance variables, and adds it to the ‘#all` list.
-
.find_by_name(name) ⇒ Object
Look up Language by its proper name.
Instance Method Summary collapse
-
#group ⇒ Language
Get Language group.
-
#initialize(attributes) ⇒ Language
constructor
Internal: Applies all the given attributes to instance variables.
-
#popular? ⇒ Boolean
Is it popular?.
-
#searchable? ⇒ Boolean
Is it searchable?.
-
#type ⇒ Symbol
Get type.
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_mode ⇒ Object (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 |
#aliases ⇒ Object (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_type ⇒ Object (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_mode ⇒ Object (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 |
#color ⇒ Object (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 |
#extensions ⇒ Object (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 |
#filenames ⇒ Object (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_name ⇒ Object (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 |
#interpreters ⇒ Object (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_id ⇒ Object (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 |
#name ⇒ Object (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_scope ⇒ Object (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 |
#wrap ⇒ Object (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
.all ⇒ Array<Language>
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.
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
#group ⇒ Language
Get Language group
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?
97 98 99 |
# File 'lib/linguists_field_guide.rb', line 97 def popular? @popular end |
#searchable? ⇒ Boolean
Is it searchable?
102 103 104 |
# File 'lib/linguists_field_guide.rb', line 102 def searchable? @searchable end |
#type ⇒ Symbol
Get type.
92 93 94 |
# File 'lib/linguists_field_guide.rb', line 92 def type @type.to_sym end |