Class: CfSim::PointList

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/cf_sim/point_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*points) ⇒ PointList

Returns a new instance of PointList.



13
14
15
# File 'lib/cf_sim/point_list.rb', line 13

def initialize(*points)
  @points = points.flatten.freeze
end

Instance Attribute Details

#pointsObject (readonly)

Returns the value of attribute points.



10
11
12
# File 'lib/cf_sim/point_list.rb', line 10

def points
  @points
end

Instance Method Details

#==(other) ⇒ Object



33
34
35
# File 'lib/cf_sim/point_list.rb', line 33

def ==(other)
  eql?(other)
end

#creatable_field_countObject



21
22
23
# File 'lib/cf_sim/point_list.rb', line 21

def creatable_field_count
  @creatable_field_count ||= points.combination(3).size
end

#creatable_fieldsObject



25
26
27
# File 'lib/cf_sim/point_list.rb', line 25

def creatable_fields
  @creatable_fields ||= CfSim::ControlFieldSet.new(points.combination(3).map { |a, b, c| CfSim::ControlField.new(a, b, c) })
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/cf_sim/point_list.rb', line 29

def eql?(other)
  other.class == CfSim::PointList && @points == other.points
end

#max_field_countObject



17
18
19
# File 'lib/cf_sim/point_list.rb', line 17

def max_field_count
  @max_field_count ||= 3 * (points.length - 3) + 1
end