Class: Snipcheat::Snippet
- Inherits:
-
Object
- Object
- Snipcheat::Snippet
- Defined in:
- lib/snipcheat/snippet.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#tab_trigger ⇒ Object
readonly
Returns the value of attribute tab_trigger.
Instance Method Summary collapse
-
#initialize(path) ⇒ Snippet
constructor
A new instance of Snippet.
- #load ⇒ Object
Constructor Details
#initialize(path) ⇒ Snippet
Returns a new instance of Snippet.
7 8 9 10 |
# File 'lib/snipcheat/snippet.rb', line 7 def initialize(path) @path = path load end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
6 7 8 |
# File 'lib/snipcheat/snippet.rb', line 6 def content @content end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
6 7 8 |
# File 'lib/snipcheat/snippet.rb', line 6 def description @description end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
6 7 8 |
# File 'lib/snipcheat/snippet.rb', line 6 def scope @scope end |
#tab_trigger ⇒ Object (readonly)
Returns the value of attribute tab_trigger.
6 7 8 |
# File 'lib/snipcheat/snippet.rb', line 6 def tab_trigger @tab_trigger end |
Instance Method Details
#load ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/snipcheat/snippet.rb', line 12 def load mash.each do |key, value| underscorized = key.to_s .gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2') .gsub(/([a-z\d])([A-Z])/,'\1_\2') .tr("-", "_") .downcase instance_variable_set("@#{underscorized}", value.to_s) end end |