Class: McBlocky::Context
- Inherits:
-
Object
show all
- Includes:
- DSL
- Defined in:
- lib/mcblocky/context.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from DSL
#after, #area, #at, #chain, #chest, #cleanup, #dispenser, #dropper, #fill, #furnace, #helper, #initial, #repeat, #setblock, to_json, to_nbt, #trapped_chest
Instance Attribute Details
#last_area ⇒ Object
Returns the value of attribute last_area.
6
7
8
|
# File 'lib/mcblocky/context.rb', line 6
def last_area
@last_area
end
|
#server ⇒ Object
Returns the value of attribute server.
5
6
7
|
# File 'lib/mcblocky/context.rb', line 5
def server
@server
end
|
Class Method Details
.run_block(&block) ⇒ Object
22
23
24
25
26
|
# File 'lib/mcblocky/context.rb', line 22
def self.run_block(&block)
ctx = Context.new
ctx.instance_exec &block
return ctx
end
|
.run_file(file, dir = nil) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/mcblocky/context.rb', line 8
def self.run_file(file, dir=nil)
dir = File.dirname(file) unless dir
Dir.chdir dir do
begin
ctx = Context.new
f = open(file)
ctx.instance_eval(f.read, file)
return ctx
ensure
f.close if f
end
end
end
|
Instance Method Details
#blocks ⇒ Object
44
45
46
|
# File 'lib/mcblocky/context.rb', line 44
def blocks
@blocks ||= {}
end
|
#chains ⇒ Object
36
37
38
|
# File 'lib/mcblocky/context.rb', line 36
def chains
@chains ||= []
end
|
#context ⇒ Object
52
53
54
|
# File 'lib/mcblocky/context.rb', line 52
def context
self
end
|
#helpers ⇒ Object
28
29
30
|
# File 'lib/mcblocky/context.rb', line 28
def helpers
@helpers ||= []
end
|
#named_chains ⇒ Object
40
41
42
|
# File 'lib/mcblocky/context.rb', line 40
def named_chains
@named_chains ||= {}
end
|
#rects ⇒ Object
48
49
50
|
# File 'lib/mcblocky/context.rb', line 48
def rects
@rects ||= {}
end
|
#require(file) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/mcblocky/context.rb', line 56
def require(file)
if file.start_with? './'
file = "#{file.sub('./','')}.rb" unless file.end_with? '.rb'
required_files << file
begin
f = open(file)
instance_eval(f.read, file)
true
ensure
f.close if f
end
else
Kernel.require(file)
end
end
|
#require_relative(file) ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/mcblocky/context.rb', line 72
def require_relative(file)
path = File.dirname caller[0].split('.rb')[0]
file = "#{file}.rb" unless file.end_with? '.rb'
file = File.expand_path(file, path)
required_files << file
begin
f = open(file)
instance_eval(f.read, file)
true
ensure
f.close if f
end
end
|
#required_files ⇒ Object
32
33
34
|
# File 'lib/mcblocky/context.rb', line 32
def required_files
@required_files ||= Set.new
end
|