Class: Cheatorious::Writer::Alfred

Inherits:
Object
  • Object
show all
Defined in:
lib/cheatorious/writer/alfred.rb

Instance Method Summary collapse

Constructor Details

#initializeAlfred

Returns a new instance of Alfred.



6
7
8
9
10
11
# File 'lib/cheatorious/writer/alfred.rb', line 6

def initialize
  @section_stack = []
  @result        = ""
  @query         = nil
  @options       = {}
end

Instance Method Details

#entry(name, *values) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/cheatorious/writer/alfred.rb', line 37

def entry(name, *values)
  value_text = values.join(", ")
  if @options['reverse']
    line "  <item arg=\"#{name}\">"
    line "    <subtitle>#{value_text}</subtitle>"
    line "    <title>#{@section_stack.join(" > ")} > #{name}</title>"
  else
    line "  <item arg=\"#{value_text}\">"
    line "    <title>#{value_text}</title>"
    line "    <subtitle>#{@section_stack.join(" > ")} > #{name}</subtitle>"
  end
  line "    <icon></icon>"
  line "  </item>"
end


25
26
27
# File 'lib/cheatorious/writer/alfred.rb', line 25

def footer
  line "</items>"
end

#header(name, author = "", version = "", description = "") ⇒ Object



13
14
15
16
# File 'lib/cheatorious/writer/alfred.rb', line 13

def header(name, author = "", version = "", description = "")
  line "<?xml version=\"1.0\"?>"
  line "<items>"
end

#resultObject



52
53
54
# File 'lib/cheatorious/writer/alfred.rb', line 52

def result
  @result
end

#search_header(query, results_count, options) ⇒ Object



18
19
20
21
22
23
# File 'lib/cheatorious/writer/alfred.rb', line 18

def search_header(query, results_count, options)
  @query = query
  @options = options
  line "<?xml version=\"1.0\"?>"
  line "<items>"
end

#section_endObject



33
34
35
# File 'lib/cheatorious/writer/alfred.rb', line 33

def section_end
  @section_stack.pop
end

#section_start(section) ⇒ Object



29
30
31
# File 'lib/cheatorious/writer/alfred.rb', line 29

def section_start(section)
  @section_stack.push(section)
end