import { Item , ItemValue } from '../../item' ; import { ItemSection } from './item-section' ; import { ItemSectionType } from './item-section-type' ; const AUGMENTED_PHRASE = ' (augmented)' ; export abstract class ItemSectionParserService { public abstract parse ( sections , target , ... options ) ; constructor ( public readonly type , public readonly optional ) { } protected parseItemValue ( text ) { const augmented = text . includes ( AUGMENTED_PHRASE ) ; text = text . replace ( AUGMENTED_PHRASE , '' ) ; const values = text . split ( '-' ) ; const value = values . map ( x => x . split ( '/' ) [ 0 ] ) . map ( x => + x . replace ( '%' , '' ) ) . reduce ( ( a , b ) => a + b , 0 ) / values . length ; const result = { text , value , augmented } ; return result ; } }