Class: Scenic::Cascade::View

Inherits:
Object
  • Object
show all
Defined in:
lib/scenic/cascade/view.rb

Overview

Represents a view

Direct Known Subclasses

ViewWithVersion

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, materialized:) ⇒ View

Returns a new instance of View.

Raises:

  • (TypeError)


9
10
11
12
13
14
15
# File 'lib/scenic/cascade/view.rb', line 9

def initialize(name:, materialized:)
  raise TypeError unless name.is_a?(String)
  raise TypeError unless materialized.is_a?(TrueClass) || materialized.is_a?(FalseClass)

  @name = name
  @materialized = materialized
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/scenic/cascade/view.rb', line 7

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object



25
26
27
# File 'lib/scenic/cascade/view.rb', line 25

def ==(other)
  name == other.name && materialized? == other.materialized?
end

#formatted_nameObject



21
22
23
# File 'lib/scenic/cascade/view.rb', line 21

def formatted_name
  name.include?('.') ? %("#{name}") : ":#{name}"
end

#materialized?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/scenic/cascade/view.rb', line 17

def materialized?
  @materialized
end

#to_sObject Also known as: inspect



29
30
31
# File 'lib/scenic/cascade/view.rb', line 29

def to_s
  "#{name} (#{materialized? ? 'MV' : 'V'})"
end