Skip to content

Commit

Permalink
Add comment in interface
Browse files Browse the repository at this point in the history
  • Loading branch information
drewsonne committed Aug 23, 2020
1 parent 095df2a commit 9bb1617
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/comment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export default class Comment {
content: string;

constructor(content: string) {
this.content = content
}

merge(other: Comment): Comment {
return new Comment(`${this} ${other}`)
}

toString(): string {
return this.content
}
}
4 changes: 3 additions & 1 deletion src/cr/calendar-round.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import NumberCoefficient from "./component/numberCoefficient";
import {Wildcard} from "../wildcard";
import WildcardCoefficient from "./component/wildcardCoefficient";
import IPart from "../i-part";
import Comment from '../comment';

/** @ignore */
const singleton: { [key: string]: CalendarRound } = {};
Expand Down Expand Up @@ -37,6 +38,7 @@ export function getCalendarRound(
export class CalendarRound implements IPart {
tzolkin: Tzolkin;
haab: Haab;
comment: Comment | undefined;

constructor(tzolkin: Tzolkin, haab: Haab) {
/**
Expand All @@ -50,7 +52,7 @@ export class CalendarRound implements IPart {

this.validate();
}

/**
* Validate that the Calendar Round has a correct 260-day and Haab
* configuration
Expand Down
2 changes: 2 additions & 0 deletions src/cr/haab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import NumberCoefficient from "./component/numberCoefficient";
import {coefficientParser as _} from "./component/coefficient";
import ICoefficient from "./component/iCoefficient";
import IPart from "../i-part";
import Comment from "../comment";

const singleton: { [key: string]: Haab } = {};

Expand Down Expand Up @@ -37,6 +38,7 @@ export function getHaab(coeff: ICoefficient, month: Wildcard | HaabMonth): Haab
export class Haab implements IPart {
coeff: ICoefficient;
month: Wildcard | HaabMonth;
comment: Comment | undefined;
_privateNext: null | Haab;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/cr/tzolkin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import NumberCoefficient from "./component/numberCoefficient";
import WildcardCoefficient from "./component/wildcardCoefficient";
import ICoefficient from "./component/iCoefficient"
import IPart from "../i-part";
import Comment from "../comment";

const singleton: { [key: string]: Tzolkin } = {};

Expand Down Expand Up @@ -36,6 +37,7 @@ export function getTzolkin(coeff: ICoefficient, day: TzolkinDay | Wildcard): Tzo
export class Tzolkin implements IPart {
day: TzolkinDay | Wildcard;
coeff: ICoefficient;
comment: Comment | undefined;
_privateNext: Tzolkin | null;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/full-date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import LongCount from "./lc/long-count";
import {CalendarRound} from "./cr/calendar-round";
import IPart from "./i-part";
import Comment from "./comment";

export default class FullDate implements IPart {

cr: CalendarRound;
lc: LongCount;
comment: Comment | undefined;

constructor(cr: CalendarRound, lc: LongCount) {
this.cr = cr;
Expand Down
4 changes: 4 additions & 0 deletions src/i-part.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import Comment from "./comment";

export default interface IPart {
comment: Comment | undefined;

equal(other: IPart): boolean;
}
2 changes: 2 additions & 0 deletions src/lc/distance-number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import {isWildcard, Wildcard} from "../wildcard";
import LongcountAddition from "../operations/longcount-addition";
import LongcountSubtraction from "../operations/longcount-subtraction";
import IPart from "../i-part";
import Comment from "../comment";

export default class DistanceNumber implements IPart {
parts: (number | Wildcard)[];
datePattern: RegExp;
sign: number;
comment: Comment | undefined

/**
* @param {...number|Wildcard} cycles - Components in the long count
Expand Down
2 changes: 2 additions & 0 deletions src/operations/calendar-round-wildcard.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import CalendarRoundIterator from './calendar-round-iter';
import {CalendarRound} from "../cr/calendar-round";
import IPart from "../i-part";
import Comment from '../comment';

/**
* A reusable singleton instance of the CalendarRoundIterator
Expand All @@ -15,6 +16,7 @@ const iter = new CalendarRoundIterator();
*/
export default class CalendarRoundWildcard implements IPart {
private cr: CalendarRound;
comment: Comment | undefined;

/**
* @param {CalendarRound} cr
Expand Down
2 changes: 2 additions & 0 deletions src/operations/fulldate-wildcard.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import FullDate from '../full-date';
import LongCountWildcard from './longcount-wildcard';
import IPart from "../i-part";
import Comment from '../comment';

/** @ignore */
// const concat = (x, y) => x.concat(y);
Expand All @@ -20,6 +21,7 @@ import IPart from "../i-part";
*/
export default class FullDateWildcard implements IPart {
private fullDate: FullDate;
comment: Comment | undefined;

/**
* @param {FullDate} partialDate
Expand Down
2 changes: 2 additions & 0 deletions src/operations/longcount-addition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import LongCount from "../lc/long-count";
import ILongcount from "./ILongcount";
import DistanceNumber from "../lc/distance-number";
import IPart from "../i-part";
import Comment from "../comment";

export default class LongcountAddition implements IPart {
private a: DistanceNumber;
private b: DistanceNumber
private LcClass: ILongcount;
comment: Comment | undefined;

/**
* @param {object} lcClass - Special param to pass the LongCount class into this operator to
Expand Down
2 changes: 2 additions & 0 deletions src/operations/longcount-subtraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import ILongcount from "./ILongcount";
import LongCount from "../lc/long-count";
import DistanceNumber from "../lc/distance-number";
import IPart from "../i-part";
import Comment from "../comment";

export default class LongcountSubtraction implements IPart {
private a: DistanceNumber
private b: DistanceNumber
private LcClass: ILongcount
comment: Comment | undefined;

/**
* @param {object} lcClass - Special param to pass the LongCount class into this operator to
Expand Down
2 changes: 2 additions & 0 deletions src/operations/longcount-wildcard.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import LongCount from "../lc/long-count";
import IPart from "../i-part";
import Comment from "../comment";

/**
* Given a Long Count with a wildcard, calculate all possible matching fully
* qualified Long Counts.
*/
export default class LongCountWildcard implements IPart {
private lc: LongCount;
comment: Comment | undefined;

/**
* @param {LongCount} lc
Expand Down
2 changes: 2 additions & 0 deletions src/wildcard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
* > true
*/
import IPart from "./i-part";
import Comment from "./comment";

export class Wildcard implements IPart {
comment: Comment | undefined;
/**
* Represent the Wildcard as a string. ie, '*'.
* @returns {string}
Expand Down

0 comments on commit 9bb1617

Please sign in to comment.