class ShinyWookie::Document
Attributes
content[RW]
Public Class Methods
new()
click to toggle source
# File lib/shiny_wookie/document.rb, line 7 def initialize @content = generate_content end
Public Instance Methods
write_to_file(*args)
click to toggle source
# File lib/shiny_wookie/document.rb, line 11 def write_to_file *args options = args.last.is_a?(Hash) ? args.last : {} prefix = (options.member?(:prefix) ? options[:prefix] : "") name = (options.member?(:name) ? options[:name] : nil) suffix = (options.member?(:suffix) ? options[:suffix] : "") extension = (options.member?(:extension) ? options[:extension] : "txt") raise ArgumentError if name.nil? File.open("#{prefix}#{name}#{suffix}.#{extension}", "w") { |f| f.write @content } end
Private Instance Methods
generate_content()
click to toggle source
# File lib/shiny_wookie/document.rb, line 26 def generate_content sentences = rand(10..100) @content = ShinyWookie.gabbler.sentence sentences.times { @content << ShinyWookie.gabbler.sentence << " " } @content end