Class: Problem
- Inherits:
-
Object
- Object
- Problem
- Defined in:
- lib/asker/data/problem.rb
Constant Summary collapse
- @@id =
0
Instance Attribute Summary collapse
-
#asks ⇒ Object
Returns the value of attribute asks.
-
#cases ⇒ Object
Returns the value of attribute cases.
-
#context ⇒ Object
Returns the value of attribute context.
-
#descs ⇒ Object
Returns the value of attribute descs.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#lang ⇒ Object
Returns the value of attribute lang.
-
#process ⇒ Object
Returns the value of attribute process.
-
#questions ⇒ Object
Returns the value of attribute questions.
-
#varnames ⇒ Object
Returns the value of attribute varnames.
Class Method Summary collapse
Instance Method Summary collapse
- #desc ⇒ Object
-
#initialize ⇒ Problem
constructor
A new instance of Problem.
- #name ⇒ Object
- #process? ⇒ Boolean
- #validate ⇒ Object
Constructor Details
#initialize ⇒ Problem
Returns a new instance of Problem.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/asker/data/problem.rb', line 15 def initialize @@id += 1 @id = @@id @lang = nil @context = nil @process = false @filename = "?" @varnames = [] @cases = [] @descs = [] @asks = [] @questions = [] end |
Instance Attribute Details
#asks ⇒ Object
Returns the value of attribute asks.
11 12 13 |
# File 'lib/asker/data/problem.rb', line 11 def asks @asks end |
#cases ⇒ Object
Returns the value of attribute cases.
9 10 11 |
# File 'lib/asker/data/problem.rb', line 9 def cases @cases end |
#context ⇒ Object
Returns the value of attribute context.
5 6 7 |
# File 'lib/asker/data/problem.rb', line 5 def context @context end |
#descs ⇒ Object
Returns the value of attribute descs.
10 11 12 |
# File 'lib/asker/data/problem.rb', line 10 def descs @descs end |
#filename ⇒ Object
Returns the value of attribute filename.
7 8 9 |
# File 'lib/asker/data/problem.rb', line 7 def filename @filename end |
#lang ⇒ Object
Returns the value of attribute lang.
4 5 6 |
# File 'lib/asker/data/problem.rb', line 4 def lang @lang end |
#process ⇒ Object
Returns the value of attribute process.
6 7 8 |
# File 'lib/asker/data/problem.rb', line 6 def process @process end |
#questions ⇒ Object
Returns the value of attribute questions.
12 13 14 |
# File 'lib/asker/data/problem.rb', line 12 def questions @questions end |
#varnames ⇒ Object
Returns the value of attribute varnames.
8 9 10 |
# File 'lib/asker/data/problem.rb', line 8 def varnames @varnames end |
Class Method Details
.from(values) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/asker/data/problem.rb', line 29 def self.from(values) problem = Problem.new fields = %i[filename varnames cases descs asks] fields.each do |fieldname| methodname = "#{fieldname}=".to_sym problem.send(methodname, values[fieldname]) end problem.validate problem end |
Instance Method Details
#desc ⇒ Object
40 41 42 |
# File 'lib/asker/data/problem.rb', line 40 def desc @descs.first end |
#name ⇒ Object
48 49 50 |
# File 'lib/asker/data/problem.rb', line 48 def name "problem#{@id}" end |
#process? ⇒ Boolean
44 45 46 |
# File 'lib/asker/data/problem.rb', line 44 def process? @process end |
#validate ⇒ Object
52 53 54 55 56 57 |
# File 'lib/asker/data/problem.rb', line 52 def validate validate_varnames validate_cases validate_asks validate_descs end |