Class: Rly::Shortcuts

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

Overview

shortcuts repository

Instance Method Summary collapse

Constructor Details

#initializeShortcuts

Returns a new instance of Shortcuts.



6
7
8
9
10
# File 'lib/rly/shortcuts.rb', line 6

def initialize
  @name = Dir.pwd.tr('/', '')
  @filename = %(/var/lib/rly/#{@name}.json)
  @shortcuts = read
end

Instance Method Details

#allObject



12
13
14
# File 'lib/rly/shortcuts.rb', line 12

def all
  @shortcuts
end

#create(name, url) ⇒ Object



24
25
26
27
# File 'lib/rly/shortcuts.rb', line 24

def create(name, url)
  @shortcuts[name] = url
  save
end

#destroy(name) ⇒ Object



29
30
31
32
# File 'lib/rly/shortcuts.rb', line 29

def destroy(name)
  @shortcuts.delete(name)
  save
end

#exist?(name) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/rly/shortcuts.rb', line 20

def exist?(name)
  @shortcuts.key?(name)
end

#find(name) ⇒ Object



16
17
18
# File 'lib/rly/shortcuts.rb', line 16

def find(name)
  @shortcuts[name]
end