Skill.purs 927 B

1234567891011121314151617181920212223242526272829303132333435
  1. module LinkedIn.Profile.Skill where
  2. import Prelude
  3. import Data.Either (Either, note)
  4. import Data.Foldable (findMap)
  5. import Data.Generic.Rep (class Generic)
  6. import Data.Maybe (Maybe(..))
  7. import Data.Show.Generic (genericShow)
  8. import LinkedIn.ArtDecoTab (ArtDecoTabElement, toHeaderBold)
  9. import LinkedIn.DetachedNode (DetachedNode)
  10. import LinkedIn.Profile.Utils (toUIElement)
  11. import LinkedIn.UIElements.Types (UIElement(..), UIString(..))
  12. data Skill = Skill {
  13. name :: String
  14. }
  15. derive instance Generic Skill _
  16. instance Show Skill where
  17. show = genericShow
  18. fromUI ∷ ArtDecoTabElement DetachedNode → Either String Skill
  19. fromUI (tab) = ado
  20. name <- note "No position found" $ findMap extractName bold
  21. in
  22. Skill { name }
  23. where
  24. asUI = toUIElement <$> tab
  25. bold = toHeaderBold asUI
  26. extractName :: UIElement -> Maybe String
  27. extractName = case _ of
  28. UIElement (UIStringPlain str) -> Just str
  29. _ -> Nothing