Class: ToLua::Generator::State
Instance Attribute Summary collapse
-
#depth ⇒ Object
Returns the value of attribute depth.
-
#indent ⇒ Object
Returns the value of attribute indent.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #configure(opts) ⇒ Object
-
#initialize(opts = {}) ⇒ State
constructor
A new instance of State.
- #pretty? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ State
Returns a new instance of State.
21 22 23 24 25 26 |
# File 'lib/to_lua/generator.rb', line 21 def initialize(opts = {}) @pretty = false @depth = 0 @indent = ' ' configure(opts) end |
Instance Attribute Details
#depth ⇒ Object
Returns the value of attribute depth.
6 7 8 |
# File 'lib/to_lua/generator.rb', line 6 def depth @depth end |
#indent ⇒ Object
Returns the value of attribute indent.
6 7 8 |
# File 'lib/to_lua/generator.rb', line 6 def indent @indent end |
Class Method Details
.from_state(opts) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/to_lua/generator.rb', line 8 def self.from_state(opts) case when self === opts opts when opts.respond_to?(:to_hash) new(opts.to_hash) when opts.respond_to?(:to_h) new(opts.to_h) else new end end |
Instance Method Details
#==(other) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/to_lua/generator.rb', line 45 def ==(other) if other.is_a? State self.to_h == other.to_h else false end end |
#configure(opts) ⇒ Object
28 29 30 31 |
# File 'lib/to_lua/generator.rb', line 28 def configure(opts) @pretty = opts[:pretty] if opts.key?(:pretty) @indent = opts[:indent] if opts.key?(:indent) end |
#pretty? ⇒ Boolean
33 34 35 |
# File 'lib/to_lua/generator.rb', line 33 def pretty? @pretty end |
#to_h ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/to_lua/generator.rb', line 37 def to_h { pretty: @pretty, indent: @indent, depth: @depth } end |