import * as cheerio from "cheerio" ; import { BoxrecCommonTableHeader , getColumnDataByColumnHeader } from "../../../helpers" ; import { BoxrecBasic } from "../../boxrec.constants" ; export abstract class BoxrecPageEventCommonRow { protected readonly $ : CheerioStatic ; constructor ( protected headerColumns , boxrecBodyBout , additionalData = null ) { const html = `<table><tr>${ boxrecBodyBout }</tr><tr>${ additionalData }</tr></table>` ; this . $ = cheerio . load ( html ) ; } get venue ( ) : BoxrecBasic { const html = this . $ ( `<div>${ getColumnDataByColumnHeader ( this . $ , this . headerColumns , BoxrecCommonTableHeader . venue ) }</div>` ) ; const venue = { id : null , name : null , } ; html . find ( "a" ) . each ( ( i , elem ) => { const href = this . $ ( elem ) . get ( 0 ) . attribs . href . match ( /(\d+)$/ ) ; if ( href ) { venue . name = this . $ ( elem ) . text ( ) ; venue . id = parseInt ( href [ 1 ] , 10 ) ; } } ) ; return venue ; } }