Class: Wordsmith::Template

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: nil, slug: nil, project: nil, **attributes) ⇒ Template

Returns a new instance of Template.



4
5
6
7
8
9
# File 'lib/wordsmith/template.rb', line 4

def initialize(name: nil, slug: nil, project: nil, **attributes)
  raise "Missing required keyword arguments" unless [name, slug, project].all?
  @name = name
  @slug = slug
  @project = project
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/wordsmith/template.rb', line 2

def name
  @name
end

#projectObject (readonly)

Returns the value of attribute project.



2
3
4
# File 'lib/wordsmith/template.rb', line 2

def project
  @project
end

#slugObject (readonly)

Returns the value of attribute slug.



2
3
4
# File 'lib/wordsmith/template.rb', line 2

def slug
  @slug
end

Instance Method Details

#generate(data) ⇒ Object



11
12
13
# File 'lib/wordsmith/template.rb', line 11

def generate(data)
  Wordsmith.client.post "projects/#{project.slug}/templates/#{slug}/outputs", data
end