class AsciiParadise::ParseStaticAscii

Attributes

message_callout_sentinel[RW]
message_callout_symbol[RW]
message_sentinel[RW]
#

Note that the various .ascii files will keep the entries for message_sentinel, message_callout_symbol and message_callout_sentinel within that respective file.

This explains why eval is used - we will eval on the header.

#

Public Class Methods

new( this_template_file, run_already = true ) click to toggle source
#

initialize

The first argument must be the path to the template file in question.

#
# File lib/ascii_paradise/ascii_say/parse_static_ascii.rb, line 39
def initialize(
    this_template_file,
    run_already = true
  )
  reset
  set_path_to_the_template_file(
    this_template_file
  )
  run if run_already
end

Public Instance Methods

alignment()
Alias for: alignment?
alignment=(i) click to toggle source
#

alignment=

#
# File lib/ascii_paradise/ascii_say/parse_static_ascii.rb, line 215
def alignment=(i)
  @alignment = i
end
alignment?() click to toggle source
#

alignment?

#
# File lib/ascii_paradise/ascii_say/parse_static_ascii.rb, line 208
def alignment?
  @alignment
end
Also aliased as: alignment
ee(i = nil)
Alias for: print
parse(i) click to toggle source
#

parse

Input to this method should be an Array.

#
# File lib/ascii_paradise/ascii_say/parse_static_ascii.rb, line 79
def parse(i)
  array = i.split(/^---\n/) # Split on lines starting with --- and then a newline.
  # ======================================================================= #
  # === Get rid of comments. This seems to be unnecessary, though.
  #     It is retained here in the event that we may wish to support
  #     comments in these files one day.
  # ======================================================================= #
  # array.reject! {|entry| entry.strip.start_with? '#' }
  # ======================================================================= #
  # Our .ascii file typically has a header and a body section. Obtain
  # each section next.
  # ======================================================================= #
  header, body = array
  binding.eval(header) # <- The header includes 3 instance variables.
  set_body(body) # Set the body.
end
parse_the_template_file(i = @path_to_the_template_file) click to toggle source
#

parse_the_template_file

#
# File lib/ascii_paradise/ascii_say/parse_static_ascii.rb, line 222
def parse_the_template_file(i = @path_to_the_template_file)
  parse(
    File.read(i)
  )
end
print(i = nil) click to toggle source
#

print

#
Also aliased as: ee, say
reset() click to toggle source
#

reset

#
# File lib/ascii_paradise/ascii_say/parse_static_ascii.rb, line 63
def reset
  @alignment = :center
end
run() click to toggle source
#

run

#
# File lib/ascii_paradise/ascii_say/parse_static_ascii.rb, line 231
def run
  parse_the_template_file
end
say(i = nil)
Alias for: print
set_body(i) click to toggle source
#

set_body

#
# File lib/ascii_paradise/ascii_say/parse_static_ascii.rb, line 70
def set_body(i)
  @body = i
end
set_path_to_the_template_file(i) click to toggle source
#

set_path_to_the_template_file

Set to the path where the template file at hand is kept. This is important, as otherwise the class will not be able to work properly.

#
# File lib/ascii_paradise/ascii_say/parse_static_ascii.rb, line 56
def set_path_to_the_template_file(i)
  @path_to_the_template_file = i
end