Class: Moon::Vector1

Inherits:
Object show all
Includes:
Comparable, Serializable, Serializable::Properties
Defined in:
lib/moon/packages/std/vector1.rb

Instance Method Summary collapse

Instance Method Details

#<=>(other) ⇒ Integer

Returns:


20
21
22
# File 'lib/moon/packages/std/vector1.rb', line 20

def <=>(other)
  [x] <=> Vector1.extract(other)
end

#[](index) ⇒ Float

Parameters:

Returns:


36
37
38
39
40
# File 'lib/moon/packages/std/vector1.rb', line 36

def [](index)
  case index
  when :x, 'x', 0 then x
  end
end

#[]=(index, value) ⇒ Object

Parameters:


44
45
46
47
48
# File 'lib/moon/packages/std/vector1.rb', line 44

def []=(index, value)
  case index
  when :x, 'x', 0 then self.x = value
  end
end

#absObject


50
51
52
# File 'lib/moon/packages/std/vector1.rb', line 50

def abs
  Moon::Vector1.new x.abs
end

#sumFloat

Returns:


10
11
12
# File 'lib/moon/packages/std/vector1.rb', line 10

def sum
  x
end

#to_hHash<Symbol, Float>

Returns:


25
26
27
# File 'lib/moon/packages/std/vector1.rb', line 25

def to_h
  { x: x }
end

#to_sString

Returns:


30
31
32
# File 'lib/moon/packages/std/vector1.rb', line 30

def to_s
  "#{x}"
end

#zero?Boolean

Returns:


15
16
17
# File 'lib/moon/packages/std/vector1.rb', line 15

def zero?
  x == 0
end