Class: Markaby::Fragment

Inherits:
BasicObject
Defined in:
lib/markaby/builder.rb

Overview

Every tag method in Markaby returns a Fragment. If any method gets called on the Fragment, the tag is removed from the Markaby stream and given back as a string. Usually the fragment is never used, though, and the stream stays intact.

For a more practical explanation, check out the README.

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Fragment

Returns a new instance of Fragment.



238
239
240
241
# File 'lib/markaby/builder.rb', line 238

def initialize(*args)
  @stream, @start, @length = args
  @transformed_stream = false
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missingObject (private)



255
256
257
258
# File 'lib/markaby/builder.rb', line 255

def method_missing(...)
  transform_stream unless transformed_stream?
  @str.__send__(...)
end

Instance Method Details

#to_sObject Also known as: to_str



247
248
249
250
# File 'lib/markaby/builder.rb', line 247

def to_s
  transform_stream unless transformed_stream?
  @str.to_s
end