Class: Shortcuts::Shortcut

Inherits:
Object
  • Object
show all
Defined in:
lib/bujo/shortcuts/shortcut.rb

Direct Known Subclasses

ThisMonthShortcut, TodayShortcut

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, source, target) ⇒ Shortcut

Returns a new instance of Shortcut.



7
8
9
10
11
# File 'lib/bujo/shortcuts/shortcut.rb', line 7

def initialize(name, source, target)
  @name = name
  @source = source
  @target = target
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/bujo/shortcuts/shortcut.rb', line 5

def name
  @name
end

#sourceObject (readonly)

Returns the value of attribute source.



5
6
7
# File 'lib/bujo/shortcuts/shortcut.rb', line 5

def source
  @source
end

#targetObject (readonly)

Returns the value of attribute target.



5
6
7
# File 'lib/bujo/shortcuts/shortcut.rb', line 5

def target
  @target
end

Instance Method Details

#createObject



13
14
15
16
# File 'lib/bujo/shortcuts/shortcut.rb', line 13

def create
  puts("* #{@name} link: #{@source} --> #{@target}")
  FileUtils.copy("target/#{@source}", "target/#{@target}") if (File.exist?("target/#{@source}"))
end

#to_sObject



18
19
20
# File 'lib/bujo/shortcuts/shortcut.rb', line 18

def to_s
  "#{@name}: #{@source} --> #{@target}"
end