lyrical_meter/
lyrical_meter.rs

1crate::ix!();
2
3#[derive(Default,ItemWithFeatures,RandConstruct,Hash,Debug,Clone,Serialize,Deserialize,PartialEq,Eq)]
4#[ai("A Lyrical meter, consisting of a foot and a line length.")]
5#[ai(Display)]
6pub struct LyricalMeter {
7    foot:   MetricalFoot,
8
9    #[rand_construct(psome=0.5)]
10    #[ai(feature_if_none="The number of feet per line is flexible.")]
11    length: Option<LineLength>,
12}
13
14impl LyricalMeter {
15    /// Starts building a `LyricalMeter` using the builder pattern without any initial arguments.
16    pub fn builder() -> LyricalMeterBuilder {
17        LyricalMeterBuilder::default()
18    }
19
20    /// Returns a reference to the metrical foot.
21    pub fn foot(&self) -> &MetricalFoot {
22        &self.foot
23    }
24
25    /// Returns an optional reference to the line length, if it exists.
26    pub fn length(&self) -> Option<&LineLength> {
27        self.length.as_ref()
28    }
29
30    /// Sets the metrical foot.
31    pub fn set_foot(&mut self, foot: MetricalFoot) -> &mut Self {
32        self.foot = foot;
33        self
34    }
35
36    /// Sets the line length.
37    pub fn set_length(&mut self, length: Option<LineLength>) -> &mut Self {
38        self.length = length;
39        self
40    }
41}