1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use crate::VojaqLine;

/// A Vojaq set is an "array" of Vojaq lines.
/// 
/// The text representation of a Vojaq set is a series of lines
/// seperated by a linefeed character.
/// 
/// ``` vojaq
/// The {first} line
/// The {second} line
/// ```
#[derive(Debug, PartialEq, Eq)]
pub struct VojaqSet {
    lines : Vec<VojaqLine>
}

impl VojaqSet {
    pub fn new() -> VojaqSet {
        VojaqSet {
            lines: vec![]
        }
    }

    pub fn with_lines(lines: Vec<VojaqLine>) -> VojaqSet {
        VojaqSet {
            lines: lines
        }
    }

    pub fn lines(&self) -> &[VojaqLine] {
        self.lines.as_slice()
    }

    pub fn push(&mut self, line: VojaqLine) {
        self.lines.push(line);
    }

    pub fn get(&self, line_index: usize) -> Option<&VojaqLine> {
        self.lines.get(line_index)
    }
}