Class: Language

Inherits:
ApplicationRecord show all
Includes:
WithCaseInsensitiveSearch
Defined in:
app/models/language.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

aggregate_of, all_except, defaults, name_model_as, numbered, #save, #save_and_notify!, #save_and_notify_changes!, #update_and_notify!, update_or_create!

Class Method Details

.for_name(name) ⇒ Object



32
33
34
# File 'app/models/language.rb', line 32

def self.for_name(name)
  find_by_ignore_case!(:name, name) if name
end

Instance Method Details

#assets_urls_for(kind, content_type) ⇒ Object



78
79
80
# File 'app/models/language.rb', line 78

def assets_urls_for(kind, content_type)
  send "#{kind}_#{content_type}_urls"
end

#bridgeObject



16
17
18
# File 'app/models/language.rb', line 16

def bridge
  Mumukit::Bridge::Runner.new(runner_url)
end

#deviconObject



40
41
42
# File 'app/models/language.rb', line 40

def devicon
  self[:devicon] || name.downcase
end

#directives_comment_typeObject



74
75
76
# File 'app/models/language.rb', line 74

def directives_comment_type
  Mumukit::Directives::CommentType.parse comment_type
end

#directives_interpolationsObject



70
71
72
# File 'app/models/language.rb', line 70

def directives_interpolations
  new_directive Mumukit::Directives::Interpolations
end

#directives_sectionsObject



66
67
68
# File 'app/models/language.rb', line 66

def directives_sections
  new_directive Mumukit::Directives::Sections
end

#highlight_modeObject



20
21
22
# File 'app/models/language.rb', line 20

def highlight_mode
  self[:highlight_mode] || name
end

#import!Object



36
37
38
# File 'app/models/language.rb', line 36

def import!
  import_from_json! Mumukit::Bridge::Runner.new(runner_url).importable_info
end

#import_from_json!(json) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/models/language.rb', line 44

def import_from_json!(json)

  assign_attributes json.slice(:name,
                               :comment_type,
                               :output_content_type,
                               :prompt,
                               :extension,
                               :highlight_mode,
                               :visible_success_output,
                               :devicon,
                               :triable,
                               :queriable,
                               :stateful_console,
                               :layout_js_urls,
                               :layout_html_urls,
                               :layout_css_urls,
                               :editor_js_urls,
                               :editor_html_urls,
                               :editor_css_urls)
  save!
end

#output_content_typeObject



24
25
26
# File 'app/models/language.rb', line 24

def output_content_type
  Mumukit::ContentType.for(self[:output_content_type])
end

#to_sObject



28
29
30
# File 'app/models/language.rb', line 28

def to_s
  name
end