Class: Snippet

Inherits:
Object
  • Object
show all
Defined in:
app/models/snippet.rb

Constant Summary collapse

@@snippet_array =
[]
@@snippet_counter =
0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#codeObject (readonly)

Returns the value of attribute code.



6
7
8
# File 'app/models/snippet.rb', line 6

def code
  @code
end

#filenameObject (readonly)

Returns the value of attribute filename.



6
7
8
# File 'app/models/snippet.rb', line 6

def filename
  @filename
end

#lineObject (readonly)

Returns the value of attribute line.



6
7
8
# File 'app/models/snippet.rb', line 6

def line
  @line
end

#snippet_arrayObject

Returns the value of attribute snippet_array.



2
3
4
# File 'app/models/snippet.rb', line 2

def snippet_array
  @snippet_array
end

#titleObject (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_snippetsObject



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_snippetsObject



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_snippetsObject



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_arrayObject



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_counterObject



12
13
14
# File 'app/models/snippet.rb', line 12

def self.snippet_counter
  @@snippet_counter
end