class Remedy::Partial
Attributes
lines[RW]
Public Class Methods
new(collection = Array.new)
click to toggle source
# File lib/remedy/partial.rb, line 3 def initialize collection = Array.new @lines = Array.new self + collection end
Public Instance Methods
+(new_lines)
click to toggle source
# File lib/remedy/partial.rb, line 9 def + new_lines new_lines.each do |line| self << line end end
<<(line)
click to toggle source
# File lib/remedy/partial.rb, line 15 def << line reset_width! line = "#{line}" # opportunistically convert any object into a string @lines += clean line unless line.nil? || line.empty? end
excerpt(lines_range, width_range)
click to toggle source
# File lib/remedy/partial.rb, line 53 def excerpt lines_range, width_range self.class.new lines[lines_range].map { |line| line[width_range] } end
first()
click to toggle source
# File lib/remedy/partial.rb, line 21 def first lines.first end
join(seperator)
click to toggle source
# File lib/remedy/partial.rb, line 49 def join seperator lines.join seperator end
last()
click to toggle source
# File lib/remedy/partial.rb, line 25 def last lines.last end
length()
click to toggle source
# File lib/remedy/partial.rb, line 29 def length lines.length end
size()
click to toggle source
# File lib/remedy/partial.rb, line 37 def size Size.new length, width end
to_a()
click to toggle source
# File lib/remedy/partial.rb, line 41 def to_a lines end
to_s()
click to toggle source
# File lib/remedy/partial.rb, line 45 def to_s lines.join '\n' end
width()
click to toggle source
# File lib/remedy/partial.rb, line 33 def width @width ||= lines.max{|line| line.length }.length end
Protected Instance Methods
clean(line)
click to toggle source
# File lib/remedy/partial.rb, line 63 def clean line Array split(line) end
reset_width!()
click to toggle source
# File lib/remedy/partial.rb, line 59 def reset_width! @width = nil end
split(line)
click to toggle source
# File lib/remedy/partial.rb, line 67 def split line line.split(/\r\n|\n\r|\n|\r/) end