Class: Oppen::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/oppen.rb

Overview

Config.

Defined Under Namespace

Modules: IndentAnchor

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(indent_anchor: IndentAnchor::ON_BREAK, eager_print: false, trim_trailing_whitespaces: false, upsize_stack: false) ⇒ Config

Returns a new instance of Config.



54
55
56
57
58
59
60
# File 'lib/oppen.rb', line 54

def initialize(indent_anchor: IndentAnchor::ON_BREAK, eager_print: false,
               trim_trailing_whitespaces: false, upsize_stack: false)
  @indent_anchor = indent_anchor
  @eager_print = eager_print
  @trim_trailing_whitespaces = trim_trailing_whitespaces
  @upsize_stack = upsize_stack
end

Instance Attribute Details

#indent_anchorObject

Returns the value of attribute indent_anchor.



52
53
54
# File 'lib/oppen.rb', line 52

def indent_anchor
  @indent_anchor
end

Class Method Details

.oppenConfig

Default config for Oppen usage

Returns:



99
100
101
# File 'lib/oppen.rb', line 99

def self.oppen
  new
end

.wadler(eager_print: true, trim_trailing_whitespaces: true, upsize_stack: true) ⇒ Config

Default config for Wadler usage

Returns:



105
106
107
# File 'lib/oppen.rb', line 105

def self.wadler(eager_print: true, trim_trailing_whitespaces: true, upsize_stack: true)
  new(indent_anchor: IndentAnchor::ON_BEGIN, eager_print:, trim_trailing_whitespaces:, upsize_stack:)
end

Instance Method Details

#eager_print?Boolean

Print groups eagerly

Examples:

out = Oppen::Wadler.new (width: 13)
out.group {
  out.group {
    out.text 'abc'
    out.breakable
    out.text 'def'
  }
  out.group {
    out.text 'ghi'
    out.breakable
    out.text 'jkl'
  }
}
out.output

# eager_print: false
# =>
# abc
# defghi jkl
#
# eager_print: true
# =>
# abc defghi
# jkl

Returns:

  • (Boolean)


91
# File 'lib/oppen.rb', line 91

def eager_print? = @eager_print

#trim_trailing_whitespaces?Boolean

Returns:

  • (Boolean)


93
# File 'lib/oppen.rb', line 93

def trim_trailing_whitespaces? = @trim_trailing_whitespaces

#upsize_stack?Boolean

Returns:

  • (Boolean)


95
# File 'lib/oppen.rb', line 95

def upsize_stack? = @upsize_stack