Class: AsciiArt
- Inherits:
-
Object
- Object
- AsciiArt
- Defined in:
- lib/asciiart.rb,
lib/asciiart/version.rb
Constant Summary collapse
- VERSION =
"0.3.0"
Instance Attribute Summary collapse
-
#image_chars ⇒ Object
writeonly
Sets the attribute image_chars.
Instance Method Summary collapse
-
#initialize(path_to_file) ⇒ AsciiArt
constructor
A new instance of AsciiArt.
- #to_ascii_art(options = {}) ⇒ Object
Constructor Details
#initialize(path_to_file) ⇒ AsciiArt
Returns a new instance of AsciiArt.
15 16 17 18 19 |
# File 'lib/asciiart.rb', line 15 def initialize(path_to_file) # open-uri open will fallback to IO open URI.open(path_to_file) { |file| @data = file.read } self end |
Instance Attribute Details
#image_chars=(value) ⇒ Object (writeonly)
Sets the attribute image_chars
13 14 15 |
# File 'lib/asciiart.rb', line 13 def image_chars=(value) @image_chars = value end |
Instance Method Details
#to_ascii_art(options = {}) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/asciiart.rb', line 21 def to_ascii_art( = {}) = { width: 100, color: false, format: "text" }.merge() img = Magick::Image.from_blob(@data).first renderer = ([:format] == "text" ? AsciiRenderer::Text.new(img) : AsciiRenderer::Html.new(img)) renderer.to_ascii_art() end |