class Tutorial::Task

Attributes

code_language[R]
current_step[R]
errors[R]
name[R]

Public Class Methods

human_attribute_name(attr, _options = {}) click to toggle source
# File lib/nexmo_developer/app/models/tutorial/task.rb, line 77
def self.human_attribute_name(attr, _options = {})
  attr
end
lookup_ancestors() click to toggle source
# File lib/nexmo_developer/app/models/tutorial/task.rb, line 81
def self.lookup_ancestors
  [self]
end
make_from(name:, code_language:, current_step:) click to toggle source
# File lib/nexmo_developer/app/models/tutorial/task.rb, line 40
def self.make_from(name:, code_language:, current_step:)
  new(
    name: name,
    code_language: code_language,
    current_step: current_step
  )
end
new(name:, current_step:, code_language: nil, title: nil, description: nil) click to toggle source
# File lib/nexmo_developer/app/models/tutorial/task.rb, line 8
def initialize(name:, current_step:, code_language: nil, title: nil, description: nil)
  @name         = name
  @title        = title
  @description  = description
  @code_language = code_language
  @current_step = current_step
  @file_loader = load_file!

  @errors = ActiveModel::Errors.new(self)
end

Public Instance Methods

==(other) click to toggle source
# File lib/nexmo_developer/app/models/tutorial/task.rb, line 48
def ==(other)
  name == other.name &&
    title == other.title &&
    description == other.description &&
    current_step == other.current_step
end
active?() click to toggle source
# File lib/nexmo_developer/app/models/tutorial/task.rb, line 36
def active?
  @name == @current_step
end
description() click to toggle source
# File lib/nexmo_developer/app/models/tutorial/task.rb, line 67
def description
  @description || yaml['description']
end
eql?(other) click to toggle source
# File lib/nexmo_developer/app/models/tutorial/task.rb, line 55
def eql?(other)
  self == other
end
hash() click to toggle source
# File lib/nexmo_developer/app/models/tutorial/task.rb, line 59
def hash
  name.hash ^ title.hash ^ description.hash ^ current_step.hash
end
load_file!() click to toggle source
# File lib/nexmo_developer/app/models/tutorial/task.rb, line 19
def load_file!
  Tutorial::FileLoader.new(
    root: Tutorial.task_content_path,
    doc_name: @name,
    code_language: @code_language,
    format: 'md'
  )
end
read_attribute_for_validation(attr) click to toggle source

The following methods are needed for validation

# File lib/nexmo_developer/app/models/tutorial/task.rb, line 73
def read_attribute_for_validation(attr)
  send(attr)
end
title() click to toggle source
# File lib/nexmo_developer/app/models/tutorial/task.rb, line 63
def title
  @title || yaml['title']
end
validate!() click to toggle source
# File lib/nexmo_developer/app/models/tutorial/task.rb, line 28
def validate!
  unless ['introduction', 'conclusion', 'prerequisites'].include? name
    path.present?
  end
rescue ::Nexmo::Markdown::DocFinder::MissingDoc => _e
  @errors.add(:name, message: "could not find the file: #{name}")
end