From a5eaeb8913520f35527af1d3a5f67c38dbfc2ff2 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sun, 7 Dec 2014 20:22:54 +0100 Subject: [PATCH] Fixed Rubocop warnings --- src-ruby/lib/image.rb | 1 + src-ruby/lib/tlg0_reader.rb | 4 ++++ src-ruby/lib/tlg5_reader.rb | 12 ++++++++++++ src-ruby/lib/tlg6_reader.rb | 1 + src-ruby/lib/tlg_converter.rb | 3 +++ src-ruby/lib/tlg_reader.rb | 5 +++-- 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src-ruby/lib/image.rb b/src-ruby/lib/image.rb index c8c0dae..4e32d22 100644 --- a/src-ruby/lib/image.rb +++ b/src-ruby/lib/image.rb @@ -1,3 +1,4 @@ +# A class that represents an abstract image. class Image attr_accessor :width attr_accessor :height diff --git a/src-ruby/lib/tlg0_reader.rb b/src-ruby/lib/tlg0_reader.rb index 0a9a825..578078a 100644 --- a/src-ruby/lib/tlg0_reader.rb +++ b/src-ruby/lib/tlg0_reader.rb @@ -4,6 +4,10 @@ require 'rubygems' require 'RMagick' +# A TLG reader that handles TLG "version" 0. +# +# TLG0 is just a wrapper for TLG5/TLG6 that puts additional data at the end of +# the file. Currently, the only data it supports are tags. class Tlg0Reader < TlgReader MAGIC = "\x54\x4c\x47\x30\x2e\x30\x00\x73\x64\x73\x1a" diff --git a/src-ruby/lib/tlg5_reader.rb b/src-ruby/lib/tlg5_reader.rb index 215ba3d..5b45fa0 100644 --- a/src-ruby/lib/tlg5_reader.rb +++ b/src-ruby/lib/tlg5_reader.rb @@ -2,6 +2,7 @@ require_relative 'tlg_reader' require 'stringio' +# A TLG reader that handles TLG version 5. class Tlg5Reader < TlgReader MAGIC = "\x54\x4c\x47\x35\x2e\x30\x00\x72\x61\x77\x1a" @@ -146,9 +147,15 @@ def decompress_block(block_info) block_info.block_data = output_data end + # A block information. class Tlg5BlockInfo + # Is decompressed? attr_reader :mark + + # The size of :block_data. attr_reader :block_size + + # It holds enough data to read up to :block_size pixel rows for one channel. attr_accessor :block_data def initialize(file) @@ -158,6 +165,7 @@ def initialize(file) end end + # A header of TLG5 file. class Tlg5Header attr_reader :channel_count attr_reader :image_width @@ -172,8 +180,12 @@ def initialize(file) end end + # Holds TLG5 compression state. class Tlg5CompressorState + # dictionary used by the modified LZW compression algorithm attr_reader :text + + # offset within the dictionary attr_accessor :offset def initialize diff --git a/src-ruby/lib/tlg6_reader.rb b/src-ruby/lib/tlg6_reader.rb index 2ae661d..5162bc2 100644 --- a/src-ruby/lib/tlg6_reader.rb +++ b/src-ruby/lib/tlg6_reader.rb @@ -1,5 +1,6 @@ require_relative 'tlg_reader' +# A TLG reader that handles TLG version 6. class Tlg6Reader < TlgReader MAGIC = "\x54\x4c\x47\x36\x2e\x30\x00\x72\x61\x77\x1a" diff --git a/src-ruby/lib/tlg_converter.rb b/src-ruby/lib/tlg_converter.rb index c4bea25..21bd25a 100644 --- a/src-ruby/lib/tlg_converter.rb +++ b/src-ruby/lib/tlg_converter.rb @@ -4,11 +4,14 @@ require 'rubygems' require 'RMagick' +# TLG to PNG converter. class TlgConverter + # Reads the TLG and returns instance to itself. def self.read(input_path) new(input_path) end + # Saves the image as PNG (or any other image, based on file extension). def save(output_path) img = Magick::Image.new(@reader.width, @reader.height) diff --git a/src-ruby/lib/tlg_reader.rb b/src-ruby/lib/tlg_reader.rb index 21bd012..56989e5 100644 --- a/src-ruby/lib/tlg_reader.rb +++ b/src-ruby/lib/tlg_reader.rb @@ -1,9 +1,10 @@ +# A base class for all TLG reader implementations. class TlgReader def read(input_path) open(input_path, 'rb') { |file| read_stream(file) } end - def read_stream(file) - fail 'Implement me' + def read_stream(_file) + fail 'Implement me in a derived class' end end