Class: Oshpark::Project

Inherits:
Object
  • Object
show all
Includes:
Dimensionable, Model, RemoteModel, Stateful
Defined in:
lib/oshpark/project.rb

Constant Summary collapse

STATES =
%w| NEW APPROVED AWAITING_REMOVAL |

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Dimensionable

#area_in_square_inches, #area_in_square_mm, #height_in_inches, #height_in_mm, #width_in_inches, #width_in_mm

Methods included from Stateful

included

Methods included from RemoteModel

#destroy!, included, #reload!, #save!

Methods included from Model

#dirty?, included, #initialize

Class Method Details

.attrsObject



5
6
7
# File 'lib/oshpark/project.rb', line 5

def self.attrs
  %w| id design_file_url name description top_image bottom_image width_in_mils height_in_mils pcb_layers state layers order_options is_shared |
end

.write_attrsObject



9
10
11
# File 'lib/oshpark/project.rb', line 9

def self.write_attrs
  %w| name description |
end

Instance Method Details

#approveObject



48
49
50
# File 'lib/oshpark/project.rb', line 48

def approve
  reload_with Oshpark::client.approve_project id
end

#bottom_imageObject



24
25
26
# File 'lib/oshpark/project.rb', line 24

def bottom_image
  Image.from_json @bottom_image
end

#height_in_milsObject



44
45
46
# File 'lib/oshpark/project.rb', line 44

def height_in_mils
  @height_in_mils || 0
end

#layersObject



28
29
30
31
32
# File 'lib/oshpark/project.rb', line 28

def layers
  @layers.map do |json|
    Layer.from_json json
  end
end

#order_optionsObject



34
35
36
37
38
# File 'lib/oshpark/project.rb', line 34

def order_options
  @order_options.map do |json|
    OrderOption.from_json json
  end
end

#top_imageObject



20
21
22
# File 'lib/oshpark/project.rb', line 20

def top_image
  Image.from_json @top_image
end

#width_in_milsObject



40
41
42
# File 'lib/oshpark/project.rb', line 40

def width_in_mils
  @width_in_mils || 0
end