Class: Gistim::Create
- Inherits:
-
Object
- Object
- Gistim::Create
- Defined in:
- lib/gistim/create.rb
Instance Attribute Summary collapse
-
#alias_name ⇒ Object
readonly
Returns the value of attribute alias_name.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #description ⇒ Object
- #directory ⇒ Object
- #hash ⇒ Object
- #hash_file_path ⇒ Object
- #implement ⇒ Object
-
#initialize(description: nil, alias_name: nil) ⇒ Create
constructor
A new instance of Create.
- #name ⇒ Object
- #url_file_path ⇒ Object
Constructor Details
#initialize(description: nil, alias_name: nil) ⇒ Create
Returns a new instance of Create.
3 4 5 6 |
# File 'lib/gistim/create.rb', line 3 def initialize(description: nil, alias_name: nil) @alias_name = alias_name @description = description end |
Instance Attribute Details
#alias_name ⇒ Object (readonly)
Returns the value of attribute alias_name.
8 9 10 |
# File 'lib/gistim/create.rb', line 8 def alias_name @alias_name end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'lib/gistim/create.rb', line 8 def url @url end |
Instance Method Details
#description ⇒ Object
28 29 30 |
# File 'lib/gistim/create.rb', line 28 def description @description ||= '# Hello Gist!' end |
#directory ⇒ Object
40 41 42 |
# File 'lib/gistim/create.rb', line 40 def directory "#{Gistim::Command.home}/#{name}" end |
#hash ⇒ Object
24 25 26 |
# File 'lib/gistim/create.rb', line 24 def hash url.nil? ? nil : url.chomp.gsub(/\A.+\//, '') end |
#hash_file_path ⇒ Object
32 33 34 |
# File 'lib/gistim/create.rb', line 32 def hash_file_path "#{directory}/.hash" end |
#implement ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/gistim/create.rb', line 10 def implement File.write(initialize_file_path, description) @url = create_empty clone File.write(url_file_path, url) File.write(hash_file_path, hash) File.delete(initialize_file_path) self end |
#name ⇒ Object
44 45 46 |
# File 'lib/gistim/create.rb', line 44 def name alias_name || hash end |
#url_file_path ⇒ Object
36 37 38 |
# File 'lib/gistim/create.rb', line 36 def url_file_path "#{directory}/.url" end |