Class: Screenomat::DSL::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/screenomat/dsl/builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code = '', &block) ⇒ Builder

Returns a new instance of Builder.



8
9
10
11
12
13
14
15
16
# File 'lib/screenomat/dsl/builder.rb', line 8

def initialize(code = '', &block)
  @sessions = []

  if !code.empty?
    instance_eval(code)
  else
    instance_eval(&block)
  end
end

Instance Attribute Details

#sessionsObject (readonly)

Returns the value of attribute sessions.



6
7
8
# File 'lib/screenomat/dsl/builder.rb', line 6

def sessions
  @sessions
end

Instance Method Details

#[](key) ⇒ Object



30
31
32
# File 'lib/screenomat/dsl/builder.rb', line 30

def [](key)
  @sessions.find { |session| session.name == key }
end

#firstObject



26
27
28
# File 'lib/screenomat/dsl/builder.rb', line 26

def first
  @sessions.first
end

#session(name = nil, &block) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/screenomat/dsl/builder.rb', line 18

def session(name = nil, &block)
  name ||= "screenie-#{Time.now.to_i}"

  session = Session.new(name.to_sym, &block)

  @sessions << session
end