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
- #implement ⇒ Object
-
#initialize(description: nil, alias_name: nil) ⇒ Create
constructor
A new instance of Create.
- #name ⇒ 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
25 26 27 |
# File 'lib/gistim/create.rb', line 25 def description @description ||= '# Hello Gist!' end |
#directory ⇒ Object
29 30 31 |
# File 'lib/gistim/create.rb', line 29 def directory "#{Gistim::Command.home}/#{name}" end |
#hash ⇒ Object
21 22 23 |
# File 'lib/gistim/create.rb', line 21 def hash url.nil? ? nil : url.chomp.gsub(/\A.+\//, '') end |
#implement ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/gistim/create.rb', line 10 def implement File.write(initialize_file_path, description) @url = create_empty clone File.delete(initialize_file_path) self end |
#name ⇒ Object
33 34 35 |
# File 'lib/gistim/create.rb', line 33 def name alias_name || hash end |