Class: Typedeploy::Kit

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

Defined Under Namespace

Classes: Family

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, data) ⇒ Kit

Returns a new instance of Kit.



6
7
8
9
10
# File 'lib/typedeploy/kit.rb', line 6

def initialize(id, data)
  @kid = id
  @data = data
  @api = Api.new
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



3
4
5
# File 'lib/typedeploy/kit.rb', line 3

def data
  @data
end

#kidObject

Returns the value of attribute kid.



4
5
6
# File 'lib/typedeploy/kit.rb', line 4

def kid
  @kid
end

Instance Method Details

#createObject



16
17
18
# File 'lib/typedeploy/kit.rb', line 16

def create
  @api.create(self)
end

#familiesObject



39
40
41
# File 'lib/typedeploy/kit.rb', line 39

def families
  @data['families'].map { |f| Family.new(f) }
end

#publishObject



12
13
14
# File 'lib/typedeploy/kit.rb', line 12

def publish
  @api.publish(@kid)
end

#to_paramsObject



43
44
45
46
47
48
49
50
51
# File 'lib/typedeploy/kit.rb', line 43

def to_params
  params = {'domains' => @data['domains'].join(",")}

  ['name', 'badge', 'analytics'].each do |attr|
    params[attr] = @data[attr]
  end

  params
end

#to_sObject



53
54
55
# File 'lib/typedeploy/kit.rb', line 53

def to_s
  "<Kit #{@data['name']}:#{to_params.inspect}>"
end