Class: Cocoslicer::Rect

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(orig_point = Point.new, size = Size.new) ⇒ Rect

Returns a new instance of Rect.



69
70
71
72
# File 'lib/cocoslicer.rb', line 69

def initialize(orig_point = Point.new, size = Size.new)
  @orig = orig_point
  @size = size
end

Instance Attribute Details

#origObject

Returns the value of attribute orig.



66
67
68
# File 'lib/cocoslicer.rb', line 66

def orig
  @orig
end

#sizeObject

Returns the value of attribute size.



66
67
68
# File 'lib/cocoslicer.rb', line 66

def size
  @size
end

Instance Method Details

#import_from_str(str) ⇒ Object



74
75
76
77
78
79
80
# File 'lib/cocoslicer.rb', line 74

def import_from_str(str)
  match = @@re.match(str)

  @orig = Point.new( match[1].to_i, match[2].to_i )
  @size = Size.new( match[3].to_i, match[4].to_i )
  return self
end

#to_cmd_str(rotated) ⇒ Object



82
83
84
# File 'lib/cocoslicer.rb', line 82

def to_cmd_str(rotated)
  return @size.to_cmd_str(rotated) + @orig.to_cmd_str
end

#to_sObject



86
87
88
# File 'lib/cocoslicer.rb', line 86

def to_s
  return "{orig=#{@orig},size=#{@size}}"
end