Class: VimGet::Output

Inherits:
Object
  • Object
show all
Defined in:
lib/vimget/output.rb

Overview

Output information in special format Supported format: plain, xml, (rss)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(format = "plain") ⇒ Output

Returns a new instance of Output.



17
18
19
# File 'lib/vimget/output.rb', line 17

def initialize(format = "plain")
  @format = format
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



16
17
18
# File 'lib/vimget/output.rb', line 16

def format
  @format
end

Instance Method Details

#detail(script) ⇒ Object



53
54
55
# File 'lib/vimget/output.rb', line 53

def detail(script)
  
end

#long(script_array) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/vimget/output.rb', line 44

def long(script_array)
  if @format == "plain"
    script_array.each do |s|
      puts "[#{s.name}]"
      puts ""
    end
  end
end

#short(script_array) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/vimget/output.rb', line 21

def short(script_array)
  if @format == "plain"
    script_array.each do |s|
      if s.installed?
        ver = "#{s.version} (#{s.installed})"
      else
        ver = "#{s.version}"
      end
      printf("%-30s %-10s\n", s.name, ver)
    end
  elsif @format == "xml"
    # simply implement
    puts "<scripts>"
    script_array.each do |s|
      puts "  <script name='#{s.name}' version='#{s.version}' installed='#{s.installed}'/>"
    end
    puts "</scripts>"
    
  else
    
  end
end