Class: AlgebraDB::Build::Between

Inherits:
Struct
  • Object
show all
Defined in:
lib/algebra_db/build/between.rb

Overview

A BETWEEN expression builder.

Constant Summary collapse

VALID_TYPES =
%i[between not_between between_symmetric not_between_symmetric].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(between_type, choose, start, finish) ⇒ Between

Returns a new instance of Between.

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
# File 'lib/algebra_db/build/between.rb', line 8

def initialize(between_type, choose, start, finish)
  super(between_type, choose, start, finish)

  return if VALID_TYPES.include?(between_type)

  raise ArgumentError, "#{between_type} must be one of #{VALID_TYPES.inspect}"
end

Instance Attribute Details

#between_typeObject

Returns the value of attribute between_type

Returns:

  • (Object)

    the current value of between_type



5
6
7
# File 'lib/algebra_db/build/between.rb', line 5

def between_type
  @between_type
end

#chooseObject

Returns the value of attribute choose

Returns:

  • (Object)

    the current value of choose



5
6
7
# File 'lib/algebra_db/build/between.rb', line 5

def choose
  @choose
end

#finishObject

Returns the value of attribute finish

Returns:

  • (Object)

    the current value of finish



5
6
7
# File 'lib/algebra_db/build/between.rb', line 5

def finish
  @finish
end

#startObject

Returns the value of attribute start

Returns:

  • (Object)

    the current value of start



5
6
7
# File 'lib/algebra_db/build/between.rb', line 5

def start
  @start
end

Instance Method Details

#render_syntax(builder) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/algebra_db/build/between.rb', line 16

def render_syntax(builder)
  choose.render_syntax(builder)
  builder.text(between_type.to_s.gsub('_', ' ').upcase)
  start.render_syntax(builder)
  builder.text('AND')
  finish.render_syntax(builder)
end