class Estreet::BlockStatement

Attributes

statements[R]

Public Class Methods

flatten(*statements) click to toggle source
# File lib/estreet/block_statement.rb, line 23
def self.flatten(*statements)
  new(*statements.flat_map do |stmt|
    if stmt.is_a? self
      stmt.statements
    else
      stmt.to_statement
    end
  end)
rescue NoMethodError => e
  raise TypeError, "Can't convert to statement: #{statements.inspect}"
end
new(*statements) click to toggle source
# File lib/estreet/block_statement.rb, line 3
def initialize(*statements)
  @statements = statements.map do |st|
    st.to_statement
    # raise TypeError, "Not a statement: #{st}" unless st.is_a? Statement
  end
end

Public Instance Methods

<<(statement) click to toggle source

Add another statement to the end of the receiver block

# File lib/estreet/block_statement.rb, line 19
def <<(statement)
  self.class.flatten(self, statement)
end
attributes() click to toggle source
Calls superclass method
# File lib/estreet/block_statement.rb, line 10
def attributes
  super.merge(body: @statements)
end
to_block() click to toggle source
# File lib/estreet/block_statement.rb, line 14
def to_block
  self
end