work on dividing line

This commit is contained in:
2025-04-07 19:44:51 +03:00
parent ab1d335f8e
commit 0e308ce77f
3 changed files with 51 additions and 31 deletions
+19 -10
View File
@@ -1,15 +1,24 @@
from collections.abc import Sized
def check(string: str):
if len(string) != 1:
raise ValueError
class BaseDividingLine:
def __init__(self, unit_part: check):
def __init__(self, unit_part: str = '-'):
self.unit_part = unit_part
def get_unit_part(self):
if len(self.unit_part) == 0:
return ' '
else:
return self.unit_part[0]
class StaticDividingLine(BaseDividingLine):
def __init__(self, unit_part: str = '-', length: int = 25):
super().__init__(unit_part)
self.length = length
def get_full_line(self):
return f'\n[dim]{self.length * self.get_unit_part()}[/dim]\n'
class DynamicDividingLine(BaseDividingLine):
def get_full_line(self, length: int):
return f'\n[dim]{self.get_unit_part() * length}[/dim]\n'
BaseDividingLine('sygu')