Class: Diff2Xml::Diff2Rss20
- Inherits:
-
Object
- Object
- Diff2Xml::Diff2Rss20
- Defined in:
- lib/diff2xml/diff2rss20.rb
Instance Attribute Summary collapse
-
#desc ⇒ Object
Returns the value of attribute desc.
-
#lang ⇒ Object
Returns the value of attribute lang.
-
#ostream ⇒ Object
writeonly
Sets the attribute ostream.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #common_line(line) ⇒ Object
- #end_block ⇒ Object
- #end_document ⇒ Object
- #end_parse ⇒ Object
-
#initialize(os = STDOUT, url = 'http://localhost/', title = 'Diff2Xml', desc = 'Diff RSS', lang = 'en-us') ⇒ Diff2Rss20
constructor
A new instance of Diff2Rss20.
- #source_line(line) ⇒ Object
- #start_block(sourceBase, sourceLength, targetBase, targetLength) ⇒ Object
- #start_document(source, target) ⇒ Object
-
#start_parse ⇒ Object
Override.
- #target_line(line) ⇒ Object
Methods included from XmlTool
#convert_illegal_characters, #convert_space, #sanitize
Constructor Details
#initialize(os = STDOUT, url = 'http://localhost/', title = 'Diff2Xml', desc = 'Diff RSS', lang = 'en-us') ⇒ Diff2Rss20
Returns a new instance of Diff2Rss20.
44 45 46 47 48 49 50 51 52 |
# File 'lib/diff2xml/diff2rss20.rb', line 44 def initialize(os = STDOUT, url = 'http://localhost/', title = 'Diff2Xml', desc = 'Diff RSS', lang = 'en-us') @ostream = os @url = url @title = title @desc = desc @lang = lang @now = Time.now @str_buffer = '' end |
Instance Attribute Details
#desc ⇒ Object
Returns the value of attribute desc.
38 39 40 |
# File 'lib/diff2xml/diff2rss20.rb', line 38 def desc @desc end |
#lang ⇒ Object
Returns the value of attribute lang.
38 39 40 |
# File 'lib/diff2xml/diff2rss20.rb', line 38 def lang @lang end |
#ostream=(value) ⇒ Object (writeonly)
Sets the attribute ostream
39 40 41 |
# File 'lib/diff2xml/diff2rss20.rb', line 39 def ostream=(value) @ostream = value end |
#title ⇒ Object
Returns the value of attribute title.
38 39 40 |
# File 'lib/diff2xml/diff2rss20.rb', line 38 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
38 39 40 |
# File 'lib/diff2xml/diff2rss20.rb', line 38 def url @url end |
Instance Method Details
#common_line(line) ⇒ Object
113 114 115 116 |
# File 'lib/diff2xml/diff2rss20.rb', line 113 def common_line(line) line = sanitize(line) @str_buffer << "<tr><td bgcolor=\"#dddddd\"><tt>#{line}</tt></td></tr>" end |
#end_block ⇒ Object
99 100 101 |
# File 'lib/diff2xml/diff2rss20.rb', line 99 def end_block @str_buffer << "</table>" end |
#end_document ⇒ Object
88 89 90 |
# File 'lib/diff2xml/diff2rss20.rb', line 88 def end_document @str_buffer << "]]>\n</description>\n</item>" end |
#end_parse ⇒ Object
69 70 71 72 73 |
# File 'lib/diff2xml/diff2rss20.rb', line 69 def end_parse @str_buffer << "</channel>\n</rss>" @str_buffer = Kconv.toutf8(@str_buffer) @ostream.print @str_buffer end |
#source_line(line) ⇒ Object
103 104 105 106 |
# File 'lib/diff2xml/diff2rss20.rb', line 103 def source_line(line) line = sanitize(line) @str_buffer << "<tr><td bgcolor=\"#aaaaaa\"><tt>#{line}</tt></td></tr>" end |
#start_block(sourceBase, sourceLength, targetBase, targetLength) ⇒ Object
92 93 94 95 96 97 |
# File 'lib/diff2xml/diff2rss20.rb', line 92 def start_block(sourceBase, sourceLength, targetBase, targetLength) @str_buffer << <<BLOCK <h3>From #{sourceBase} to #{sourceBase.to_i+sourceLength.to_i}</h3> <table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\"> BLOCK end |
#start_document(source, target) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/diff2xml/diff2rss20.rb', line 75 def start_document(source, target) @str_buffer << <<HEADER <item> <title>#{source}</title> <link>#{@url}##{source}</link> <author>Diff2Xml::Diff2Rss20</author> <pubDate>#{@now}</pubDate> <description> <![CDATA[ HEADER @now = @now.succ end |
#start_parse ⇒ Object
Override
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/diff2xml/diff2rss20.rb', line 58 def start_parse @str_buffer << <<HEAD <?xml version=\"1.0\" encoding=\"UTF-8\"?> <rss version=\"2.0\"> <channel> <title>#{@title}</title> <description>#{@desc}</description> <language>#{@lang}/language> HEAD end |
#target_line(line) ⇒ Object
108 109 110 111 |
# File 'lib/diff2xml/diff2rss20.rb', line 108 def target_line(line) line = sanitize(line) @str_buffer << "<tr><td bgcolor=\"#ffff00\"><tt>#{line}</tt></td></tr>" end |