Class: Snippet
- Inherits:
-
Object
- Object
- Snippet
- Defined in:
- app/models/snippet.rb
Constant Summary collapse
- @@snippet_array =
[]
- @@snippet_counter =
0
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#snippet_array ⇒ Object
Returns the value of attribute snippet_array.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
- .erb_snippets ⇒ Object
- .js_snippets ⇒ Object
- .rb_snippets ⇒ Object
- .snippet_array ⇒ Object
- .snippet_array=(arg) ⇒ Object
- .snippet_counter ⇒ Object
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Snippet
constructor
A new instance of Snippet.
Constructor Details
#initialize(args = {}) ⇒ Snippet
Returns a new instance of Snippet.
32 33 34 35 36 37 38 39 |
# File 'app/models/snippet.rb', line 32 def initialize(args = {}) @code = args[:code] @title = args[:title] @@snippet_array << self @@snippet_counter += 1 @line = args[:line] @filename = args[:filename] end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'app/models/snippet.rb', line 6 def code @code end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
6 7 8 |
# File 'app/models/snippet.rb', line 6 def filename @filename end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
6 7 8 |
# File 'app/models/snippet.rb', line 6 def line @line end |
#snippet_array ⇒ Object
Returns the value of attribute snippet_array.
2 3 4 |
# File 'app/models/snippet.rb', line 2 def snippet_array @snippet_array end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
6 7 8 |
# File 'app/models/snippet.rb', line 6 def title @title end |
Class Method Details
.erb_snippets ⇒ Object
24 25 26 |
# File 'app/models/snippet.rb', line 24 def self.erb_snippets @@snippet_array.select {|snippet| snippet.filename.end_with?(".erb") || snippet.filename.end_with?("(.erb)") } end |
.js_snippets ⇒ Object
28 29 30 |
# File 'app/models/snippet.rb', line 28 def self.js_snippets @@snippet_array.select {|snippet| snippet.filename.end_with?(".js") || snippet.filename.end_with?("(.js)") } end |
.rb_snippets ⇒ Object
20 21 22 |
# File 'app/models/snippet.rb', line 20 def self.rb_snippets @@snippet_array.select {|snippet| snippet.filename.end_with?(".rb") || snippet.filename.end_with?("(.rb)")} end |
.snippet_array ⇒ Object
8 9 10 |
# File 'app/models/snippet.rb', line 8 def self.snippet_array @@snippet_array end |
.snippet_array=(arg) ⇒ Object
16 17 18 |
# File 'app/models/snippet.rb', line 16 def self.snippet_array=(arg) @@snippet_array = arg end |
.snippet_counter ⇒ Object
12 13 14 |
# File 'app/models/snippet.rb', line 12 def self.snippet_counter @@snippet_counter end |