Skip to content
This repository has been archived by the owner on Apr 25, 2022. It is now read-only.

Commit

Permalink
Fixed Rubocop warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Kurczewski committed Dec 7, 2014
1 parent 75f13e6 commit a5eaeb8
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions src-ruby/lib/image.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# A class that represents an abstract image.
class Image
attr_accessor :width
attr_accessor :height
Expand Down
4 changes: 4 additions & 0 deletions src-ruby/lib/tlg0_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
12 changes: 12 additions & 0 deletions src-ruby/lib/tlg5_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)
Expand All @@ -158,6 +165,7 @@ def initialize(file)
end
end

# A header of TLG5 file.
class Tlg5Header
attr_reader :channel_count
attr_reader :image_width
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src-ruby/lib/tlg6_reader.rb
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
3 changes: 3 additions & 0 deletions src-ruby/lib/tlg_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 3 additions & 2 deletions src-ruby/lib/tlg_reader.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a5eaeb8

Please sign in to comment.