Class: Cheatorious::Writer::Alfred
- Inherits:
-
Object
- Object
- Cheatorious::Writer::Alfred
- Defined in:
- lib/cheatorious/writer/alfred.rb
Instance Method Summary collapse
- #entry(name, *values) ⇒ Object
- #footer ⇒ Object
- #header(name, author = "", version = "", description = "") ⇒ Object
-
#initialize ⇒ Alfred
constructor
A new instance of Alfred.
- #result ⇒ Object
- #search_header(query, results_count, options) ⇒ Object
- #section_end ⇒ Object
- #section_start(section) ⇒ Object
Constructor Details
#initialize ⇒ Alfred
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 |
#footer ⇒ Object
25 26 27 |
# File 'lib/cheatorious/writer/alfred.rb', line 25 def line "</items>" end |
#header(name, author = "", version = "", description = "") ⇒ Object
13 14 15 16 |
# File 'lib/cheatorious/writer/alfred.rb', line 13 def header(name, = "", version = "", description = "") line "<?xml version=\"1.0\"?>" line "<items>" end |
#result ⇒ Object
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, ) @query = query @options = line "<?xml version=\"1.0\"?>" line "<items>" end |
#section_end ⇒ Object
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 |