Skip to content

Commit e5118a4

Browse files
author
Nathan Campos
committed
Ready to roll
1 parent 057e0f0 commit e5118a4

File tree

3 files changed

+65
-5
lines changed

3 files changed

+65
-5
lines changed

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
11
# ascii-image
22

3-
A Ruby library to convert images into ASCII.
3+
A Ruby gem to convert images into ASCII for your awesome command-line applications.
4+
*This is my first Ruby gem*
5+
6+
7+
## Example
8+
9+
Convert an image to ASCII and print it using 20 columns of the console:
10+
11+
ascii = ASCII_Image.new("file.jpg")
12+
ascii.build(20)
13+
14+
15+
## License
16+
17+
This library is licensed under the GPLv3 license.
18+
19+
> ascii-image - A Ruby gem to convert images into ASCII.
20+
> Copyright (C) 2012 Nathan Campos
21+
>
22+
> This program is free software: you can redistribute it and/or modify
23+
> it under the terms of the GNU General Public License as published by
24+
> the Free Software Foundation, either version 3 of the License, or
25+
> (at your option) any later version.
26+
>
27+
> This program is distributed in the hope that it will be useful,
28+
> but WITHOUT ANY WARRANTY; without even the implied warranty of
29+
> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30+
> GNU General Public License for more details.
31+
>
32+
> You should have received a copy of the GNU General Public License
33+
> along with this program. If not, see <http://www.gnu.org/licenses/>.

ascii-image.gemspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Gem::Specification.new do |s|
22
s.name = "ascii-image"
3-
s.version = "0.0.1"
4-
s.date = '2012-11-03'
3+
s.version = "0.1.0"
4+
s.date = '2012-11-04'
55
s.summary = "Convert images into ASCII"
6-
s.description = "A Ruby gem to convert images into ASCII"
6+
s.description = "A Ruby gem to convert images into ASCII for your awesome command-line applications"
77
s.authors = ["Nathan Campos"]
88
s.email = "nathanpc@dreamintech.net"
99
s.files = ["lib/ascii-image.rb"]
1010
s.homepage = "https://github.com/nathanpc/ascii-image"
11-
end
11+
end

lib/ascii-image.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,30 @@
44
require 'RMagick'
55
require 'rainbow'
66

7+
# == Summary
8+
#
9+
# This handy Ruby gem will help you to create awesome ASCII art from images
10+
# for your awesome command-line projects.
11+
#
12+
# == Example
13+
#
14+
# ascii = ASCII_Image.new("file.jpg")
15+
# ascii.build(80)
16+
#
17+
# == Contact
18+
#
19+
# Author:: Nathan Campos (nathanpc@dreamintech.net)
20+
# Website:: http://about.me/nathanpc
21+
722
class ASCII_Image
23+
# Initialize the ASCII_Image class.
24+
#
25+
# An Error is raised if your ImageMagick quantum depth is higher than 8.
26+
#
27+
# Arguments:
28+
# file: (String)
29+
# console_width: (Integer)
30+
831
def initialize(file, console_width = 80)
932
@file = file
1033
@console_width = console_width
@@ -14,6 +37,13 @@ def initialize(file, console_width = 80)
1437
end
1538
end
1639

40+
# Convert the image into ASCII and print it to the console.
41+
#
42+
# An ArgumentError is raised if the +width+ is bigger than the +console_width+
43+
#
44+
# Arguments:
45+
# width: (Integer)
46+
1747
def build(width)
1848
# Open the image file
1949
image = Magick::Image.read(@file)[0]

0 commit comments

Comments
 (0)