Class: Aka::Shortcut

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commandObject

Returns the value of attribute command.



28
29
30
# File 'lib/aka/shortcut.rb', line 28

def command
  @command
end

#descriptionObject

Returns the value of attribute description.



30
31
32
# File 'lib/aka/shortcut.rb', line 30

def description
  @description
end

#functionObject

Returns the value of attribute function.



31
32
33
# File 'lib/aka/shortcut.rb', line 31

def function
  @function
end

#shortcutObject

Returns the value of attribute shortcut.



27
28
29
# File 'lib/aka/shortcut.rb', line 27

def shortcut
  @shortcut
end

#tagObject

Returns the value of attribute tag.



29
30
31
# File 'lib/aka/shortcut.rb', line 29

def tag
  @tag
end

Class Method Details

.generate_output(row) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/aka/shortcut.rb', line 13

def self.generate_output(row)
  string = if row.function
    "    function \#{row.shortcut} {\n      \#{row.command}\n    }\n    EOS\n  else\n    %{alias \#{row.shortcut}=\"\#{row.command.gsub(%{\"}, %{\\\\\"})}\"}\n  end\n\n  string\nend\n".gsub(/^        /, '')

.parse(options) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/aka/shortcut.rb', line 3

def self.parse(options)
  self.new.tap do |row|
    row.shortcut = options['shortcut']
    row.command = options['command']
    row.tag = options['tag'] if options['tag']
    row.description = options['description'] if options['description']
    row.function = options['function'] if options['function']
  end
end

Instance Method Details

#to_hashObject



33
34
35
36
37
38
39
40
41
# File 'lib/aka/shortcut.rb', line 33

def to_hash
  {
    :shortcut => self.shortcut,
    :command => self.command,
    :tag => self.tag,
    :description => self.description,
    :function => self.function
  }
end